ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2025-05-14 03:25:00
Exec Total Coverage
Lines: 9168 12116 75.7%
Functions: 376 434 86.6%
Branches: 7269 12846 56.6%

Line Branch Exec Source
1 #include "base/handles.h"
2 #include "base/zdefs.h"
3 #include <cstring>
4 #include <optional>
5 #include <stdio.h>
6 #include "base/combo.h"
7 #include "base/general.h"
8 #include "base/zc_alleg.h"
9 #include "zc/guys.h"
10 #include "zc/replay.h"
11 #include "zc/zc_ffc.h"
12 #include "zc/zc_subscr.h"
13 #include "zc/zelda.h"
14 #include "base/zsys.h"
15 #include "base/msgstr.h"
16 #include "zc/maps.h"
17 #include "zc/hero.h"
18 #include "subscr.h"
19 #include "zc/ffscript.h"
20 #include "gamedata.h"
21 #include "defdata.h"
22 #include "zscriptversion.h"
23 #include "particles.h"
24 #include "base/zc_math.h"
25 #include "slopes.h"
26 #include "base/qrs.h"
27 #include "base/dmap.h"
28 #include "base/mapscr.h"
29 #include "base/misctypes.h"
30 #include "base/initdata.h"
31 #include "zc/combos.h"
32 #include "iter.h"
33
34 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
35
36 int32_t repaircharge=0;
37 bool adjustmagic=false;
38 bool learnslash=false;
39 int32_t wallm_load_clk=0;
40 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
41 int32_t vhead=0;
42
43 char *guy_string[eMAXGUYS];
44
45 void playLevelMusic();
46
47 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
48 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
49
50 1113209 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
51 {
52 1113209 int32_t c = coord.getInt();
53
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 1112932 times.
1113209 if(nearest_half)
54 {
55
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1112932 times.
1112932 if (c < 0)
56 c -= val / 2;
57 1112932 else c += (val/2);
58 1112932 }
59 1113209 c -= c % val;
60 1113209 coord = c;
61 1113209 }
62
63 38536959 static bool OUTOFBOUNDS(int32_t id, int32_t x, int32_t y)
64 {
65
4/4
✓ Branch 0 taken 38020353 times.
✓ Branch 1 taken 516606 times.
✓ Branch 2 taken 1215 times.
✓ Branch 3 taken 38535744 times.
38536959 if (y > world_h + (isSideViewGravity() && canfall(id) ? 16 : 176)) return true;
66
2/2
✓ Branch 0 taken 30320 times.
✓ Branch 1 taken 38505424 times.
38535744 if (y < -176) return true;
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38505424 times.
38505424 if (x < -256) return true;
68
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 38505358 times.
38505424 if (x > world_w+256) return true;
69 38505358 return false;
70 38536959 }
71
72 bool NEWOUTOFBOUNDS(int32_t x, int32_t y, int32_t z)
73 {
74 return
75 (
76 (y > FFCore.enemy_removal_point[spriteremovalY2])
77 || (y < FFCore.enemy_removal_point[spriteremovalY1])
78 || (x < FFCore.enemy_removal_point[spriteremovalX1])
79 || (x > FFCore.enemy_removal_point[spriteremovalX2])
80 || (z < FFCore.enemy_removal_point[spriteremovalZ1])
81 || (z > FFCore.enemy_removal_point[spriteremovalZ2])
82 );
83 }
84
85 6674 static void position_relative_to_screen(zfix& x, zfix& y, int32_t rx, int32_t ry)
86 {
87 6674 x = rx + (x.getInt()/256)*256;
88 6674 y = ry + (y.getInt()/176)*176;
89 6674 }
90
91 namespace
92 {
93 int32_t trapConstantHorizontalID;
94 int32_t trapConstantVerticalID;
95 int32_t trapLOSHorizontalID;
96 int32_t trapLOSVerticalID;
97 int32_t trapLOS4WayID;
98
99 int32_t cornerTrapID;
100 int32_t centerTrapID;
101
102 int32_t rockID;
103 int32_t zoraID;
104 int32_t statueID;
105 }
106
107 412 void identifyCFEnemies()
108 {
109 412 trapConstantHorizontalID=-1;
110 412 trapConstantVerticalID=-1;
111 412 trapLOSHorizontalID=-1;
112 412 trapLOSVerticalID=-1;
113 412 trapLOS4WayID=-1;
114 412 cornerTrapID=-1;
115 412 centerTrapID=-1;
116 412 rockID=-1;
117 412 zoraID=-1;
118 412 statueID=-1;
119
120
2/2
✓ Branch 0 taken 210944 times.
✓ Branch 1 taken 412 times.
211356 for(int32_t i=0; i<eMAXGUYS; i++)
121 {
122
3/4
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 210538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 406 times.
210944 if((guysbuf[i].flags&guy_trph) && trapLOSHorizontalID==-1)
123 406 trapLOSHorizontalID=i;
124
4/4
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 210523 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 412 times.
210944 if((guysbuf[i].flags&guy_trpv) && trapLOSVerticalID==-1)
125 412 trapLOSVerticalID=i;
126
3/4
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 210532 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 412 times.
210944 if((guysbuf[i].flags&guy_trp4) && trapLOS4WayID==-1)
127 412 trapLOS4WayID=i;
128
3/4
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 210532 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 412 times.
210944 if((guysbuf[i].flags&guy_trplr) && trapConstantHorizontalID==-1)
129 412 trapConstantHorizontalID=i;
130
3/4
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 210532 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 412 times.
210944 if((guysbuf[i].flags&guy_trpud) && trapConstantVerticalID==-1)
131 412 trapConstantVerticalID=i;
132
133
3/4
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 210532 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 412 times.
210944 if((guysbuf[i].flags&guy_trap) && cornerTrapID==-1)
134 412 cornerTrapID=i;
135
3/4
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 210532 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 412 times.
210944 if((guysbuf[i].flags&guy_trp2) && centerTrapID==-1)
136 412 centerTrapID=i;
137
138
3/4
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 210532 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 412 times.
210944 if((guysbuf[i].flags&guy_rock) && rockID==-1)
139 412 rockID=i;
140
4/4
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 210514 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 409 times.
210944 if((guysbuf[i].flags&guy_zora) && zoraID==-1)
141 409 zoraID=i;
142
143
4/4
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 210472 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 412 times.
210944 if((guysbuf[i].flags & guy_fire) && statueID==-1)
144 412 statueID=i;
145 210944 }
146 412 }
147
148 32 int32_t random_layer_enemy(int screen)
149 {
150 32 int32_t cnt=count_layer_enemies(screen);
151 32 mapscr* base_scr = get_scr(screen);
152
153
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
154 {
155 return eNONE;
156 }
157
158 32 int32_t ret=zc_oldrand()%cnt;
159 32 cnt=0;
160
161
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
162 {
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(base_scr->layermap[i]!=0)
164 {
165 32 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
166
167
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
168 {
169
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
170 {
171
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
172 {
173 32 return layerscreen->enemy[j];
174 }
175
176 108 ++cnt;
177 108 }
178 108 }
179 }
180 }
181
182 return eNONE;
183 32 }
184
185 49 int32_t count_layer_enemies(int screen)
186 {
187 49 int32_t cnt=0;
188
189 49 mapscr* base_scr = get_scr(screen);
190
191
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
192 {
193
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if (base_scr->layermap[i])
194 {
195 79 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
196
197
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
198 {
199
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
200 {
201 420 ++cnt;
202 420 }
203 790 }
204 79 }
205 294 }
206
207 49 return cnt;
208 }
209
210 211789 int32_t hero_on_wall()
211 {
212 211789 zfix lx = Hero.getX();
213 211789 zfix ly = Hero.getY();
214
215
4/4
✓ Branch 0 taken 189837 times.
✓ Branch 1 taken 21952 times.
✓ Branch 2 taken 8850 times.
✓ Branch 3 taken 180987 times.
211789 if(lx>=48 && lx<=world_w-64)
216 {
217
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 180756 times.
180987 if(ly==32) return up+1;
218
219
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 180473 times.
180756 if(ly==world_h-48) return down+1;
220 180473 }
221
222
4/4
✓ Branch 0 taken 194033 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21403 times.
✓ Branch 3 taken 172630 times.
211275 if(ly>=48 && ly<=world_h-64)
223 {
224
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 172407 times.
172630 if(lx==32) return left+1;
225
226
2/2
✓ Branch 0 taken 172303 times.
✓ Branch 1 taken 104 times.
172407 if(lx==world_w-48) return right+1;
227 172303 }
228
229 210948 return 0;
230 211789 }
231
232 806953 bool tooclose(int32_t x,int32_t y,int32_t d)
233 {
234
2/2
✓ Branch 0 taken 600901 times.
✓ Branch 1 taken 206052 times.
806953 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
235 }
236
237 4019514 bool enemy::overpit(enemy *e)
238 {
239 // This function (and shadow_overpit) has been broken since it was written, and only
240 // checked the same diagonal of the hitbox, over and over again. The bug is because both
241 // loops used the same variable name.
242 // Checking literally every pixel seems like overkill, so for now let's continue to
243 // do the single diagonal but just once. That's why the outer loop is commented out.
244
245 // for ( int32_t q = 0; q < hxsz; ++q )
246 {
247
2/2
✓ Branch 0 taken 37189774 times.
✓ Branch 1 taken 4000312 times.
41190086 for ( int32_t q = 0; q < hit_height; ++q )
248 {
249 //check every pixel of the hitbox
250
2/2
✓ Branch 0 taken 19202 times.
✓ Branch 1 taken 37170572 times.
37189774 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
251 {
252 //if the hitbox is over a pit, we can't land
253 19202 return true;
254 }
255 37170572 }
256 }
257 4000312 return false;
258 4019514 }
259
260 12339853 bool enemy::shadow_overpit(enemy *e)
261 {
262 // for ( int32_t q = 0; q < hxsz; ++q )
263 {
264
2/2
✓ Branch 0 taken 177225346 times.
✓ Branch 1 taken 12313392 times.
189538738 for ( int32_t q = 0; q < hit_height; ++q )
265 {
266 //check every pixel of the hitbox
267
2/2
✓ Branch 0 taken 26461 times.
✓ Branch 1 taken 177198885 times.
177225346 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
268 {
269 //if the hitbox is over a pit, we can't land
270 26461 return true;
271 }
272 177198885 }
273 }
274 12313392 return false;
275 12339853 }
276
277 // Returns true iff a combo type or flag precludes enemy movement.
278 7438187 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
279 {
280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7438187 times.
7438187 if(moveflags & move_ignore_blockflags) return false;
281 7438187 int32_t c = COMBOTYPE(dx,dy);
282
4/4
✓ Branch 0 taken 4895199 times.
✓ Branch 1 taken 2542988 times.
✓ Branch 2 taken 1400387 times.
✓ Branch 3 taken 1142601 times.
9981175 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
283
3/6
✓ Branch 0 taken 2524664 times.
✓ Branch 1 taken 4913523 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2524664 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7438187 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
284
5/6
✓ Branch 0 taken 2584210 times.
✓ Branch 1 taken 4853977 times.
✓ Branch 2 taken 2582333 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 2582333 times.
✗ Branch 5 not taken.
14877138 return c==cPIT || c==cPITB || c==cPITC ||
285
4/6
✓ Branch 0 taken 2582333 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2582333 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2433585 times.
✓ Branch 5 taken 148748 times.
2582333 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
286 // Block enemies type and block enemies flags
287
2/2
✓ Branch 0 taken 2577057 times.
✓ Branch 1 taken 2428309 times.
148748 combo_class_buf[c].block_enemies&1 ||
288
4/4
✓ Branch 0 taken 2574387 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 2574140 times.
✓ Branch 3 taken 247 times.
2577057 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
289
4/4
✓ Branch 0 taken 2573322 times.
✓ Branch 1 taken 818 times.
✓ Branch 2 taken 2573256 times.
✓ Branch 3 taken 66 times.
2574140 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
290 // Check for ladder-only combos which aren't dried water
291
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 2562630 times.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 295 times.
5146217 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
292 // Check for drownable water
293
4/4
✓ Branch 0 taken 574658 times.
✓ Branch 1 taken 1998303 times.
✓ Branch 2 taken 2332 times.
✓ Branch 3 taken 572326 times.
2572961 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true, false, false)));
294 2586851 }
295
296 // Returns true iff enemy is floating and blocked by a combo type or flag.
297 8696039 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
298 {
299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8696039 times.
8696039 if(moveflags & move_ignore_blockflags) return false;
300
4/4
✓ Branch 0 taken 6597137 times.
✓ Branch 1 taken 2098902 times.
✓ Branch 2 taken 1750204 times.
✓ Branch 3 taken 348698 times.
10794941 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
301
3/4
✓ Branch 0 taken 6611644 times.
✓ Branch 1 taken 2084395 times.
✓ Branch 2 taken 2084395 times.
✗ Branch 3 not taken.
10780434 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
302
2/2
✓ Branch 0 taken 1201931 times.
✓ Branch 1 taken 7494108 times.
16190147 return ((special==spw_floater)&&
303
2/2
✓ Branch 0 taken 7483965 times.
✓ Branch 1 taken 10143 times.
7494108 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
304
2/2
✓ Branch 0 taken 7483846 times.
✓ Branch 1 taken 119 times.
7483965 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
305
2/2
✓ Branch 0 taken 7483675 times.
✓ Branch 1 taken 171 times.
7483846 (MAPFLAG(dx,dy)==mfNOENEMY)||
306
2/2
✓ Branch 0 taken 7483420 times.
✓ Branch 1 taken 255 times.
7483675 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
307
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6240891 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
14962836 (water_blocks && iswaterex_z3(MAPCOMBO(dx, dy), -1, dx,dy, false, false, true)) ||
308
2/2
✓ Branch 0 taken 6231302 times.
✓ Branch 1 taken 1248114 times.
7479416 (pit_blocks && ispitfall(dx,dy))));
309 8696039 }
310 // Returns true iff a combo type or flag precludes enemy movement.
311 282044 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
312 {
313 282044 int32_t c = COMBOTYPE(dx,dy);
314 282044 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
315
2/2
✓ Branch 0 taken 35554 times.
✓ Branch 1 taken 246490 times.
282044 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
316
5/6
✓ Branch 0 taken 282024 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 281907 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 281907 times.
✗ Branch 5 not taken.
1062873 return c==cPIT || c==cPITB || c==cPITC ||
317
4/6
✓ Branch 0 taken 281907 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 281907 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 250034 times.
✓ Branch 5 taken 31873 times.
281907 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
318 // Block enemies type and block enemies flags
319
2/2
✓ Branch 0 taken 281334 times.
✓ Branch 1 taken 249461 times.
31873 combo_class_buf[c].block_enemies&1 ||
320
4/4
✓ Branch 0 taken 280947 times.
✓ Branch 1 taken 387 times.
✓ Branch 2 taken 280916 times.
✓ Branch 3 taken 31 times.
281334 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
321
4/4
✓ Branch 0 taken 277261 times.
✓ Branch 1 taken 3655 times.
✓ Branch 2 taken 276986 times.
✓ Branch 3 taken 275 times.
280916 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
322 // Check for ladder-only combos which aren't dried water
323
4/4
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 275942 times.
✓ Branch 2 taken 1005 times.
✓ Branch 3 taken 39 times.
553933 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
324 // Check for drownable water
325
4/4
✓ Branch 0 taken 53168 times.
✓ Branch 1 taken 223779 times.
✓ Branch 2 taken 28535 times.
✓ Branch 3 taken 24633 times.
276947 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)));
326 }
327
328 // Returns true iff enemy is floating and blocked by a combo type or flag.
329 139611 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
330 {
331
2/2
✓ Branch 0 taken 137288 times.
✓ Branch 1 taken 2323 times.
139611 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
332 139611 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139611 times.
279222 return ((special==spw_floater)&&
334
2/2
✓ Branch 0 taken 139514 times.
✓ Branch 1 taken 97 times.
139611 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
335
2/2
✓ Branch 0 taken 139509 times.
✓ Branch 1 taken 5 times.
139514 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
336
2/2
✓ Branch 0 taken 139500 times.
✓ Branch 1 taken 9 times.
139509 (MAPFLAG(dx,dy)==mfNOENEMY)||
337
2/2
✓ Branch 0 taken 139471 times.
✓ Branch 1 taken 29 times.
139500 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
338
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 137150 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
278692 (water_blocks && iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)) ||
339
2/2
✓ Branch 0 taken 137150 times.
✓ Branch 1 taken 2071 times.
139221 (pit_blocks && ispitfall(dx,dy))));
340 }
341
342
5/10
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115228 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115228 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115228 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115228 times.
✗ Branch 9 not taken.
230456 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
343 115228 {
344
1/2
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
115228 x=X;
345
1/2
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
115228 y=Y;
346
3/6
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115228 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115228 times.
✗ Branch 5 not taken.
115228 screen_spawned=get_screen_for_world_xy(x.getInt(), y.getInt());
347 115228 id=Id;
348 115228 clk=Clk;
349
1/2
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
115228 floor_y=y;
350 115228 ceiling=false;
351 115228 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
352 115228 grumble = movestatus = posframe = timer = ox = oy = 0;
353
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115228 times.
✓ Branch 2 taken 115228 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115228 times.
✗ Branch 5 not taken.
115228 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
354 115228 did_armos=true;
355 115228 script_spawned=false;
356
357 115228 d = guysbuf + (id & 0xFFF);
358 115228 hp = d->hp;
359 115228 starting_hp = hp;
360 // cs = d->cset;
361 //d variables
362
363 115228 flags=d->flags;
364 115228 flags=d->flags;
365 115228 s_tile=d->s_tile; //secondary (additional) tile(s)
366 115228 family=d->family;
367 115228 dcset=d->cset;
368 115228 cs=dcset;
369
2/2
✓ Branch 0 taken 89092 times.
✓ Branch 1 taken 26136 times.
115228 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
370 115228 dp=d->dp;
371 115228 wdp=d->wdp;
372 115228 wpn=d->weapon;
373 115228 wpnsprite = d-> wpnsprite; //2.6 -Z
374 115228 rate=d->rate;
375 115228 hrate=d->hrate;
376
1/2
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
115228 dstep=d->step;
377 115228 homing=d->homing;
378 115228 dmisc1=d->attributes[0];
379 115228 dmisc2=d->attributes[1];
380 115228 dmisc3=d->attributes[2];
381 115228 dmisc4=d->attributes[3];
382 115228 dmisc5=d->attributes[4];
383 115228 dmisc6=d->attributes[5];
384 115228 dmisc7=d->attributes[6];
385 115228 dmisc8=d->attributes[7];
386 115228 dmisc9=d->attributes[8];
387 115228 dmisc10=d->attributes[9];
388 115228 dmisc11=d->attributes[10];
389 115228 dmisc12=d->attributes[11];
390 115228 dmisc13=d->attributes[12];
391 115228 dmisc14=d->attributes[13];
392 115228 dmisc15=d->attributes[14];
393 115228 dmisc16=d->attributes[15];
394 115228 dmisc17=d->attributes[16];
395 115228 dmisc18=d->attributes[17];
396 115228 dmisc19=d->attributes[18];
397 115228 dmisc20=d->attributes[19];
398 115228 dmisc21=d->attributes[20];
399 115228 dmisc22=d->attributes[21];
400 115228 dmisc23=d->attributes[22];
401 115228 dmisc24=d->attributes[23];
402 115228 dmisc25=d->attributes[24];
403 115228 dmisc26=d->attributes[25];
404 115228 dmisc27=d->attributes[26];
405 115228 dmisc28=d->attributes[27];
406 115228 dmisc29=d->attributes[28];
407 115228 dmisc30=d->attributes[29];
408 115228 dmisc31=d->attributes[30];
409 115228 dmisc32=d->attributes[31];
410
2/2
✓ Branch 0 taken 4274 times.
✓ Branch 1 taken 110954 times.
115228 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
411 {
412 110954 dmisc31 = dmisc32;
413 110954 dmisc32 = 0;
414 110954 }
415 115228 spr_shadow=d->spr_shadow;
416 115228 spr_death=d->spr_death;
417 115228 spr_spawn=d->spr_spawn;
418
419
2/2
✓ Branch 0 taken 4724348 times.
✓ Branch 1 taken 115228 times.
4839576 for(int32_t i=0; i<edefLAST255; i++)
420 4724348 defense[i]=d->defense[i];
421
422 115228 bgsfx=d->bgsfx;
423 115228 hitsfx=d->hitsfx;
424 115228 deadsfx=d->deadsfx;
425 115228 bosspal=d->bosspal;
426 115228 parent_uid = 0;
427
428 115228 frozentile = d->frozentile;
429
430 115228 frozencset = d->frozencset;
431 115228 frozenclock = 0;
432
2/2
✓ Branch 0 taken 1152280 times.
✓ Branch 1 taken 115228 times.
1267508 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
433
434
2/2
✓ Branch 0 taken 1958876 times.
✓ Branch 1 taken 115228 times.
2074104 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
435 //firesfx = 0; //t.b.a -Z
436 115228 isCore = true; //t.b.a
437 115228 parentCore = 0; //t.b.a
438
439 115228 firesfx = d->firesfx;
440
2/2
✓ Branch 0 taken 3687296 times.
✓ Branch 1 taken 115228 times.
3802524 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
441
2/2
✓ Branch 0 taken 3687296 times.
✓ Branch 1 taken 115228 times.
3802524 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
442
443 115228 script = d->script;
444 115228 weaponscript = d->weaponscript;
445
446
2/2
✓ Branch 0 taken 921824 times.
✓ Branch 1 taken 115228 times.
1037052 for ( int32_t q = 0; q < 8; q++ )
447 {
448 921824 initD[q] = d->initD[q];
449 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
450 921824 weap_initiald[q] = d->weap_initiald[q];
451 921824 }
452
453 115228 stickclk = 0;
454 115228 submerged = false;
455 115228 didScriptThisFrame = false;
456 115228 ffcactivated = std::nullopt;
457 115228 hitdir = -1;
458 115228 editorflags = d->editorflags; //set by Enemy Editor
459 //Set the drawing flag for this sprite.
460
1/2
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
115228 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
461
462
463
2/2
✓ Branch 0 taken 8921 times.
✓ Branch 1 taken 106307 times.
115228 if(bosspal>-1)
464 {
465
1/2
✓ Branch 0 taken 8921 times.
✗ Branch 1 not taken.
8921 loadpalset(csBOSS,pSprite(bosspal));
466 8921 }
467
468
2/2
✓ Branch 0 taken 50327 times.
✓ Branch 1 taken 64901 times.
115228 if(bgsfx>-1)
469 {
470
1/2
✓ Branch 0 taken 50327 times.
✗ Branch 1 not taken.
50327 cont_sfx(bgsfx);
471 50327 }
472
473
2/2
✓ Branch 0 taken 89092 times.
✓ Branch 1 taken 26136 times.
115228 if(get_qr(qr_NEWENEMYTILES))
474 {
475 89092 o_tile=d->e_tile;
476 89092 frate = d->e_frate;
477 89092 }
478 else
479 {
480 26136 o_tile=d->tile;
481 26136 frate = d->frate;
482 }
483
484 115228 tile=0; //init to 0 here, but set it later.
485
486 115228 scripttile = -1;
487 115228 scriptflip = -1;
488 115228 do_animation = true;
489 115228 immortal = false;
490 115228 noSlide = false;
491 115228 deathexstate = -1;
492
493 115228 hashero=false;
494
495 // If they forgot the invisibility flag, here's another failsafe:
496
4/4
✓ Branch 0 taken 5793 times.
✓ Branch 1 taken 109435 times.
✓ Branch 2 taken 5699 times.
✓ Branch 3 taken 94 times.
115228 if(o_tile==0 && family!=eeSPINTILE)
497
1/2
✓ Branch 0 taken 5699 times.
✗ Branch 1 not taken.
5699 flags |= guy_invisible;
498
499 // step = d->step/100.0;
500 // To preserve the odd step values for Keese & Gleeok heads. -L
501
5/8
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115228 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12297 times.
✓ Branch 5 taken 102931 times.
✓ Branch 6 taken 12297 times.
✗ Branch 7 not taken.
115228 if(dstep==62.0) dstep+=0.5;
502
5/8
✓ Branch 0 taken 102931 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102931 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 102232 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
102931 else if(dstep==89) dstep-=1/9;
503
504
5/10
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115228 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115228 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115228 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115228 times.
✗ Branch 9 not taken.
115228 step = zslongToFix(dstep*100);
505
506
507 115228 item_set = d->item_set;
508 115228 grumble = d->grumble;
509
510
2/2
✓ Branch 0 taken 90339 times.
✓ Branch 1 taken 24889 times.
115228 if(frate == 0)
511 24889 frate = 256;
512
513 115228 leader = itemguy = dying = scored = false;
514 115228 canfreeze = count_enemy = true;
515
1/2
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
115228 mainguy = !(flags & guy_doesnt_count);
516
1/2
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
115228 dir = zc_oldrand()&3;
517
518 //2.6 Enemy Editor Hit and TIle Sizes
519
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 115219 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
115228 if ( ((d->SIZEflags&OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
520 // al_trace("Enemy txsz:%i\n", txsz);
521
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 115219 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
115228 if ( ((d->SIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
522
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115221 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
115228 if ( ((d->SIZEflags&OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
523
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115221 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
115228 if ( ((d->SIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115228 if ( ((d->SIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
525
1/2
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
115228 if ( (d->SIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
526
1/2
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
115228 if ( (d->SIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
527 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
528
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115228 if ( (d->SIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115228 times.
115228 if ( (d->SIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
530 {
531 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
532 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
533 }
534
535
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115228 if ( (d->SIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
536
537 115228 SIZEflags = d->SIZEflags;
538
539
8/10
✓ Branch 0 taken 114979 times.
✓ Branch 1 taken 249 times.
✓ Branch 2 taken 366 times.
✓ Branch 3 taken 114862 times.
✓ Branch 4 taken 366 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 366 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 365 times.
115228 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
540 1 wpn = 0;
541
542 //tile should never be 0 after init --Z (failsafe)
543
4/6
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115228 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107987 times.
✓ Branch 5 taken 7241 times.
115228 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
544
545 //Moveflags; for gravity and pit interaction
546 115228 moveflags = d->moveflags;
547
3/4
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✓ Branch 3 taken 97522 times.
115228 if(!can_pitfall(false))
548 {
549 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
550
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 moveflags &= ~move_can_pitfall;
551
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 moveflags &= ~move_can_waterdrown;
552 17706 }
553
554 115228 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
555
556
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115228 if (((d->weapoverrideFLAGS & OVERRIDE_TILE_WIDTH) != 0) && d->weap_tilew > 0) { weap_tilew = d->weap_tilew; if (weap_tilew > 1) extend = 3; }
557
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115228 if (((d->weapoverrideFLAGS & OVERRIDE_TILE_HEIGHT) != 0) && d->weap_tileh > 0) { weap_tileh = d->weap_tileh; if (weap_tileh > 1) extend = 3; }
558
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115228 if (((d->weapoverrideFLAGS & OVERRIDE_HIT_WIDTH) != 0) && d->weap_hxsz >= 0) weap_hxsz = d->weap_hxsz;
559
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115228 if (((d->weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT) != 0) && d->weap_hysz >= 0) weap_hysz = d->weap_hysz;
560
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115228 if (((d->weapoverrideFLAGS & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->weap_hzsz >= 0) weap_hzsz = d->weap_hzsz;
561
1/2
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
115228 if ((d->weapoverrideFLAGS & OVERRIDE_HIT_X_OFFSET) != 0) weap_hxofs = d->weap_hxofs;
562
1/2
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
115228 if ((d->weapoverrideFLAGS & OVERRIDE_HIT_Y_OFFSET) != 0) weap_hyofs = d->weap_hyofs;
563
1/2
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
115228 if ((d->weapoverrideFLAGS & OVERRIDE_DRAW_X_OFFSET) != 0) weap_xofs = (int32_t)d->weap_xofs;
564
1/2
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
115228 if ((d->weapoverrideFLAGS & OVERRIDE_DRAW_Y_OFFSET) != 0)
565 {
566 weap_yofs = (int32_t)d->weap_yofs; //This seems to be setting to +48 or something with any value set?! -Z
567 weap_yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
568 }
569 115228 weapoverrideFLAGS = d->weapoverrideFLAGS;
570 115228 wunblockable = d->wunblockable;
571 115228 wmoveflags = d->wmoveflags;
572
2/4
✓ Branch 0 taken 115228 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115228 times.
✗ Branch 3 not taken.
115228 wstep = zslongToFix(d->wstep*100);
573 115228 memcpy(burnsprs, d->burnsprs, sizeof(d->burnsprs));
574 115228 memcpy(light_rads, d->light_rads, sizeof(d->light_rads));
575 115228 specialsfx = d->specialsfx;
576 115228 }
577
578 114975 enemy::~enemy()
579 114975 {
580
2/4
✓ Branch 0 taken 114975 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114975 times.
✗ Branch 3 not taken.
114975 FFCore.deallocateAllScriptOwned(ScriptType::NPC, getUID());
581
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 114962 times.
114975 if(hashero)
582 {
583
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 Hero.setEaten(0);
584 13 hashero=false;
585 13 }
586 114975 }
587
588 bool enemy::is_move_paused()
589 {
590 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
591 }
592
593 7024 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
594 {
595 7024 int32_t yg = (special==spw_floater)?8:0;
596 7024 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
597 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
598
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_x == -1000)
599 input_x = dx;
600
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_y == -1000)
601 input_y = dy;
602
603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
14048 if(!(moveflags & move_ignore_screenedge)
604
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7024 times.
✓ Branch 4 taken 6707 times.
✓ Branch 5 taken 317 times.
7024 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
605
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 || ((input_x+hit_width-1) >= (world_w-16+nb)) || ((input_y+hit_height-1) >= (world_h-16+nb))))
606 return true;
607
608
4/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6934 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
7024 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
609 {
610 if(ispitfall(dx,dy))
611 return true;
612 }
613
614 7024 bool flying = false;
615 7024 bool cansolid = false;
616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 if(moveflags & move_ignore_solidity)
617 cansolid = true;
618
2/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7024 switch(special)
619 {
620 case spw_clipbottomright:
621 if(dy>=128 || dx>=208) return true;
622 break;
623 case spw_clipright:
624 break; //if(input_x>=208) return true; break;
625
626 case spw_wizzrobe: // fall through
627 case spw_floater: // Special case for fliers and wizzrobes - hack!
628 {
629
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
317 if(isdungeon(screen_spawned) && !(moveflags & move_ignore_screenedge))
630 {
631 if(dy < 32-yg || dy >= 144) return true;
632 if(dx < 32 || dx >= 224) return true;
633 }
634
2/4
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
635 return true;
636 317 cansolid = true;
637 317 flying = true;
638 }
639 317 }
640
641 7024 dx = TRUNCATE_HALF_TILE(dx);
642 7024 dy = TRUNCATE_HALF_TILE(dy);
643
644
4/6
✓ Branch 0 taken 6707 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 6707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6707 times.
✗ Branch 5 not taken.
7024 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
645
646
4/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7024 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7024 times.
7024 if (dx < 0 || dx >= world_w || dy < 0 || dy >= world_h)
647 return !(moveflags & move_ignore_screenedge);
648
649 // TODO: could this reuse _walkflag?
650
651 //_walkflag code
652 7024 mapscr* s0 = get_scr_for_world_xy_layer(dx, dy, 0);
653
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 mapscr* s1 = s0->layermap[0]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 1) : nullptr;
654
2/2
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
7024 mapscr* s2 = s0->layermap[1]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 2) : nullptr;
655
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 if (!s1 || !s1->valid) s1 = s0;
656
4/4
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
✓ Branch 2 taken 383 times.
✓ Branch 3 taken 655 times.
7024 if (!s2 || !s2->valid) s2 = s0;
657
658 7024 int32_t cpos = COMBOPOS(dx%256, dy%176);
659
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 int32_t ci = s0->data[cpos], ci1 = (s1?s1:s0)->data[cpos], ci2 = (s2?s2:s0)->data[cpos];
660 7024 newcombo c = combobuf[ci];
661
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 newcombo c1 = combobuf[ci1];
662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 newcombo c2 = combobuf[ci2];
663
664 7024 int32_t b=1;
665
2/2
✓ Branch 0 taken 3446 times.
✓ Branch 1 taken 3578 times.
7024 if(dx&8) b<<=2;
666
2/2
✓ Branch 0 taken 3374 times.
✓ Branch 1 taken 3650 times.
7024 if(dy&8) b<<=1;
667
668 #define iwtr(cmb, x, y, shallow) \
669 (shallow \
670 ? iswaterex_z3(cmb, -1, dx, dy, false, false, false, true, false) \
671 && !iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false) \
672 : iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false))
673
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool wtr = iwtr(ci, dx, dy, false);
674
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3473 times.
✓ Branch 3 taken 3551 times.
✓ Branch 4 taken 3473 times.
✗ Branch 5 not taken.
7024 bool shwtr = iwtr(ci, dx, dy, true);
675
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool pit = ispitfall(dx,dy);
676
677
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 90 times.
✗ Branch 7 not taken.
7024 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
678
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 90 times.
7024 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
679
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needwtr = (moveflags & move_only_waterwalk);
680
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
681
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needpit = (moveflags & move_only_pitwalk);
682
683
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
7024 if(!cansolid)
684 {
685 6707 int32_t cwalkflag = c.walk & 0xF;
686
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6707 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s1)
688 {
689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c1.type == cBRIDGE)
690 {
691 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
692 {
693 int efflag = (c1.walk & 0xF0)>>4;
694 int newsolid = (c1.walk & 0xF);
695 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
696 }
697 else cwalkflag &= c1.walk;
698 }
699 6707 else cwalkflag |= c1.walk & 0xF;
700 6707 }
701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s2)
702 {
703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c2.type == cBRIDGE)
704 {
705 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
706 {
707 int efflag = (c2.walk & 0xF0)>>4;
708 int newsolid = (c2.walk & 0xF);
709 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
710 }
711 else cwalkflag &= c2.walk;
712 }
713 6707 else cwalkflag |= c2.walk & 0xF;
714 6707 }
715
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 6468 times.
6707 if(cwalkflag & b)
716 239 return true;
717 6468 }
718
3/6
✓ Branch 0 taken 6785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6785 times.
6785 if(needwtr || needshwtr || needpit)
719 {
720 bool ret = true;
721 if (needwtr && wtr) ret = false;
722 else if (needshwtr && shwtr) ret = false;
723 else if (needpit && pit) ret = false;
724 return ret;
725 }
726
3/4
✓ Branch 0 taken 3473 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 3473 times.
✗ Branch 3 not taken.
6785 else if(wtr && !canwtr)
727 return true;
728
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6785 else if(pit && !canpit)
729 return true;
730
731 6785 return false;
732 7024 }
733
734 1535 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
735 {
736
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1111 times.
✓ Branch 2 taken 424 times.
✗ Branch 3 not taken.
1535 if(!(dx || dy)) return true;
737 1535 zfix bx = x+hxofs, by = y+hyofs; //left/top
738 1535 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
739
3/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1019 times.
✗ Branch 3 not taken.
1535 if(!ign_sv && dy < 0) //check gravity
740 {
741 if((moveflags & move_obeys_grav) && isSideViewGravity())
742 return false;
743 }
744
745
2/4
✓ Branch 0 taken 1535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1535 times.
1535 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
746
747
3/4
✓ Branch 0 taken 1111 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1111 times.
1535 if(dx && !dy)
748 {
749
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 341 times.
1111 if(dx < 0)
750 {
751
2/4
✓ Branch 0 taken 770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 770 times.
770 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
752 770 int mx = (bx+dx).getFloor();
753
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 770 times.
3746 for(zfix ty = 0; by+ty < ry; ty += 8)
754 {
755
1/2
✓ Branch 0 taken 2976 times.
✗ Branch 1 not taken.
2976 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
756 return false;
757 2976 }
758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 770 times.
770 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
759 return false;
760
3/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
770 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
761 return false;
762 770 }
763 else
764 {
765 341 int mx = (rx+dx).getCeil();
766 341 int lx = mx-hit_width+1;
767
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 340 times.
2482 for(zfix ty = 0; by+ty < ry; ty += 8)
768 {
769
2/2
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 1 times.
2142 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
770 1 return false;
771 2141 }
772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
773 return false;
774
2/4
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
✗ Branch 3 not taken.
340 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
775 return false;
776 }
777 1110 }
778
2/4
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
424 else if(dy && !dx)
779 {
780
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 109 times.
424 if(dy < 0)
781 {
782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 special = (special==spw_clipbottomright)?spw_none:special;
783 315 int my = (by+dy).getFloor();
784
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 77 times.
469 for(zfix tx = 0; bx+tx < rx; tx += 8)
785 {
786
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 238 times.
392 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
787 238 return false;
788 154 }
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(scr_walkflag(rx, my, special, up, bx, my, kb))
790 return false;
791
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
77 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
792 return false;
793 77 }
794 else
795 {
796 109 int my = (ry+dy).getCeil();
797 109 int ly = my-hit_height+1;
798
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109 times.
327 for(zfix tx = 0; bx+tx < rx; tx += 8)
799 {
800
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
801 return false;
802 218 }
803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
804 return false;
805
3/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
109 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
806 return false;
807 }
808 186 }
809 else //! Untested, and currently unused.
810 {
811 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
812 }
813 1296 return true;
814 1535 }
815
816 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
817 {
818 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
819 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
820
821 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
822
823 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
824 return false;
825 for(zfix ty = 0; by+ty < ry; ty += 8)
826 {
827 for(zfix tx = 0; bx+tx < rx; tx += 8)
828 {
829 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
830 return false;
831 }
832 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
833 return false;
834 }
835 for(zfix tx = 0; bx+tx < rx; tx += 8)
836 {
837 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
838 return false;
839 }
840 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
841 return false;
842 return true;
843 }
844
845 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
846 {
847 auto oxsz = hit_width, oysz = hit_height;
848 if(nwid > -1) hit_width = nwid;
849 if(nhei > -1) hit_height = nhei;
850 bool ret = scr_canplace(dx,dy,special,kb);
851 hit_width = oxsz; hit_height = oysz;
852 return ret;
853 }
854
855 1311 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
856 {
857 1311 bool ret = true;
858
3/8
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1311 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
859 dy = 0;
860 1311 const int scl = 2;
861
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 1345 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 1311 times.
1605 while(abs(dx) > scl || abs(dy) > scl)
862 {
863
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 34 times.
294 if(abs(dx) > abs(dy))
864 {
865 260 int32_t tdx = dx.sign() * scl;
866
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
867 260 dx -= tdx;
868 else
869 {
870 if(earlyret) return false;
871 dx = tdx;
872 ret = false;
873 }
874 260 }
875 else
876 {
877 34 int32_t tdy = dy.sign() * scl;
878
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
879 27 dy -= tdy;
880 else
881 {
882
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(earlyret) return false;
883 7 dy = tdy;
884 7 ret = false;
885 }
886 }
887 }
888
889
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 1111 times.
1311 if(dx)
890 {
891
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 1 times.
1111 if(scr_canmove(dx, 0, special, kb, ign_sv))
892 1110 x += dx;
893 else
894 {
895
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
896 ret = false;
897 int xsign = dx.sign();
898 while(scr_canmove(xsign, 0, special, kb, ign_sv))
899 {
900 x += xsign;
901 dx -= xsign;
902 }
903 if(dx)
904 {
905 dx.doDecBound(0,-9999, 0,9999);
906 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
907 if(scr_canmove(val, 0, special, kb, ign_sv))
908 {
909 retval = val;
910 return BSEARCH_CONTINUE_AWAY0;
911 }
912 else return BSEARCH_CONTINUE_TOWARD0;
913 });
914 x += dx;
915 }
916 }
917 1110 }
918
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 200 times.
1310 if(dy)
919 {
920
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 14 times.
200 if(scr_canmove(0, dy, special, kb, ign_sv))
921 186 y += dy;
922 else
923 {
924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(earlyret) return false;
925 14 ret = false;
926 14 int ysign = dy.sign();
927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 while(scr_canmove(0, ysign, special, kb, ign_sv))
928 {
929 y += ysign;
930 dy -= ysign;
931 }
932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(dy)
933 {
934 14 dy.doDecBound(0,-9999, 0,9999);
935
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
224 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(scr_canmove(0, val, special, kb, ign_sv))
937 {
938 retval = val;
939 return BSEARCH_CONTINUE_AWAY0;
940 }
941 210 else return BSEARCH_CONTINUE_TOWARD0;
942 210 });
943 14 y += dy;
944 14 }
945 }
946 200 }
947 1310 return ret;
948 1311 }
949
950 754 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
951 {
952
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
754 static const zfix diagrate = zslongToFix(7071);
953
5/13
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 479 times.
✓ Branch 7 taken 259 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
754 switch(NORMAL_DIR(dir))
954 {
955 case up:
956 return movexy(0, -px, special, kb, false, earlyret);
957 case down:
958 16 return movexy(0, px, special, kb, false, earlyret);
959 case left:
960 479 return movexy(-px, 0, special, kb, false, earlyret);
961 case right:
962 259 return movexy(px, 0, special, kb, false, earlyret);
963 case r_up:
964 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
965 case r_down:
966 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
967 case l_up:
968 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
969 case l_down:
970 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
971 }
972 return false;
973 754 }
974
975 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
976 {
977 double v = degrees.getFloat() * PI / 180.0;
978 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
979 return movexy(dx, dy, special, kb, false, earlyret);
980 }
981
982 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
983 {
984 zfix tx = x, ty = y;
985 bool ret = movexy(dx, dy, special, kb, false, true);
986 x = tx;
987 y = ty;
988 return ret;
989 }
990 754 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
991 {
992 754 zfix tx = x, ty = y;
993 754 bool ret = moveDir(dir, px, special, kb, true);
994 754 x = tx;
995 754 y = ty;
996 754 return ret;
997 }
998 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
999 {
1000 zfix tx = x, ty = y;
1001 bool ret = moveAtAngle(degrees, px, special, kb, true);
1002 x = tx;
1003 y = ty;
1004 return ret;
1005 }
1006
1007 // Handle pitfalls
1008 37984689 bool enemy::do_falling(int32_t index)
1009 {
1010
2/2
✓ Branch 0 taken 37982322 times.
✓ Branch 1 taken 2367 times.
37984689 if(fallclk > 0)
1011 {
1012
4/4
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2333 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 20 times.
2367 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
1013
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 22 times.
2367 if(!--fallclk)
1014 {
1015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(immortal) //Keep alive forever
1016 ++fallclk; //force another frame of falling.... forever.
1017
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(dying) //Give 1 frame for script revival
1018 {
1019
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(flags&guy_never_return)
1020 never_return(screen_spawned, index);
1021
1022
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(leader)
1023 kill_em_all();
1024
1025 //leave_item(); //Don't drop items in pits!
1026 11 stop_bgsfx(index);
1027 11 return true;
1028 }
1029 else
1030 {
1031 11 try_death(true); //Force death
1032 11 ++fallclk; //force another frame of falling
1033 }
1034 11 }
1035
1036 2356 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1037 2356 cs = spr.csets & 0xF;
1038
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t fr = spr.frames ? spr.frames : 1;
1039
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t spd = spr.speed ? spr.speed : 1;
1040 2356 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1041
2/2
✓ Branch 0 taken 1148 times.
✓ Branch 1 taken 1208 times.
2356 tile = spr.tile + zc_min(animclk / spd, fr-1);
1042 2356 }
1043 37984678 return false;
1044 37984689 }
1045
1046 // Handle drowning in water
1047 37982322 bool enemy::do_drowning(int32_t index)
1048 {
1049
1/2
✓ Branch 0 taken 37982322 times.
✗ Branch 1 not taken.
37982322 if(drownclk > 0)
1050 {
1051 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
1052 //!TODO: Drown SFX
1053 if(!--drownclk)
1054 {
1055 if(immortal) //Keep alive forever
1056 ++drownclk; //force another frame of falling.... forever.
1057 else if(dying) //Give 1 frame for script revival
1058 {
1059 if(flags&guy_never_return)
1060 never_return(screen_spawned, index);
1061
1062 if(leader)
1063 kill_em_all();
1064
1065 //leave_item(); //Don't drop items in pits!
1066 stop_bgsfx(index);
1067 return true;
1068 }
1069 else
1070 {
1071 try_death(true); //Force death
1072 ++drownclk; //force another frame of falling
1073 }
1074 }
1075
1076 bool lava = (drownCombo && combobuf[drownCombo].usrflags&cflag1);
1077 wpndata &spr = wpnsbuf[QMisc.sprites[lava ? sprLAVADROWN : sprDROWN]];
1078 cs = spr.csets & 0xF;
1079 int32_t fr = spr.frames ? spr.frames : 1;
1080 int32_t spd = spr.speed ? spr.speed : 1;
1081 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1082 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1083 }
1084 37982322 return false;
1085 37982322 }
1086
1087 // Supplemental animation code that all derived classes should call
1088 // as a return value for animate().
1089 // Handles the death animation and returns true when enemy is finished.
1090 38647618 bool enemy::Dead(int32_t index)
1091 {
1092
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38645789 times.
38647618 if(immortal)
1093 {
1094 1829 dying = false;
1095 1829 return false;
1096 }
1097
2/2
✓ Branch 0 taken 765484 times.
✓ Branch 1 taken 37880305 times.
38645789 if(dying)
1098 {
1099
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 765483 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
765484 if(deathexstate > -1 && deathexstate < 32)
1100 {
1101 1 setxmapflag(screen_spawned, 1<<deathexstate);
1102 1 deathexstate = -1;
1103 1 }
1104 765484 --clk2;
1105
1106
4/4
✓ Branch 0 taken 725581 times.
✓ Branch 1 taken 39903 times.
✓ Branch 2 taken 38732 times.
✓ Branch 3 taken 3242 times.
765484 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1107
2/2
✓ Branch 0 taken 41974 times.
✓ Branch 1 taken 683607 times.
725581 && hp>-1000) // not killed by ringleader
1108 38732 death_sfx();
1109
1110
2/2
✓ Branch 0 taken 721955 times.
✓ Branch 1 taken 43529 times.
765484 if(clk2==0)
1111 {
1112
2/2
✓ Branch 0 taken 42825 times.
✓ Branch 1 taken 704 times.
43529 if(flags&guy_never_return)
1113 704 never_return(screen_spawned, index);
1114
1115
2/2
✓ Branch 0 taken 43458 times.
✓ Branch 1 taken 71 times.
43529 if(leader)
1116 71 kill_em_all();
1117
1118 43529 leave_item();
1119 43529 }
1120
1121 765484 stop_bgsfx(index);
1122 765484 return (clk2==0);
1123 }
1124
1125 37880305 return false;
1126 38647618 }
1127
1128 // Basic animation code that all derived classes should call.
1129 // The one with an index is the one that is called by
1130 // the guys sprite list; index is the enemy's index in the list.
1131 37984945 bool enemy::animate(int32_t index)
1132 {
1133
2/2
✓ Branch 0 taken 1701045 times.
✓ Branch 1 taken 36283900 times.
37984945 if(sclk <= 0) hitdir = -1;
1134
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 37984689 times.
37984945 if(switch_hooked)
1135 {
1136
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1137 {
1138 //Run its script
1139 if (!didScriptThisFrame)
1140 {
1141 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1142 {
1143 return 0; //Avoid NULLPO if this object deleted itself
1144 }
1145 }
1146 }
1147 256 return false;
1148 }
1149
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 37984678 times.
37984689 if(do_falling(index)) return true;
1150
2/2
✓ Branch 0 taken 2356 times.
✓ Branch 1 taken 37982322 times.
37984678 else if(fallclk)
1151 {
1152 //clks
1153
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 704 times.
2356 if(hclk>0)
1154 704 --hclk;
1155
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(stunclk>0)
1156 --stunclk;
1157
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if ( frozenclock > 0 )
1158 --frozenclock;
1159
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(hashero)
1160 {
1161 Hero.setX(x);
1162 Hero.setY(y);
1163 Hero.fallCombo = fallCombo;
1164 Hero.fallclk = fallclk;
1165 hashero = false; //Let Hero go if falling
1166 }
1167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2356 times.
2356 if (!didScriptThisFrame)
1168 {
1169 2356 run_script(MODE_NORMAL);
1170 2356 }
1171 2356 return false;
1172 }
1173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37982322 times.
37982322 if(do_drowning(index)) return true;
1174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37982322 times.
37982322 else if(drownclk)
1175 {
1176 //clks
1177 if(hclk>0)
1178 --hclk;
1179 if(stunclk>0)
1180 --stunclk;
1181 if ( frozenclock > 0 )
1182 --frozenclock;
1183 if(hashero)
1184 {
1185 Hero.setX(x);
1186 Hero.setY(y);
1187 Hero.drownclk = drownclk;
1188 hashero = false; //Let Hero go if falling
1189 }
1190 if (!didScriptThisFrame)
1191 {
1192 run_script(MODE_NORMAL);
1193 }
1194 return false;
1195 }
1196 37982322 int32_t nx = real_x(x);
1197 37982322 int32_t ny = real_y(y);
1198
1199
4/4
✓ Branch 0 taken 27464384 times.
✓ Branch 1 taken 10517938 times.
✓ Branch 2 taken 5657504 times.
✓ Branch 3 taken 21806880 times.
37982322 if(ox!=nx || oy!=ny)
1200 {
1201 16175442 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1202 16175442 }
1203
1204 37982322 ox = nx;
1205 37982322 oy = ny;
1206
1207 // Maybe they fell off the bottom in sideview, or were moved by a script.
1208
1209 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1210
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 37980493 times.
37982322 if ( immortal )
1211 {
1212 //skip, as it can go out of bounds, from immortality
1213 1829 }
1214
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 37980493 times.
✓ Branch 2 taken 37980493 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37980493 times.
37980493 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1215 {
1216 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1217 }
1218
2/2
✓ Branch 0 taken 37948892 times.
✓ Branch 1 taken 31601 times.
37980493 else if (OUTOFBOUNDS(id, x, y))
1219 {
1220 31601 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1221 31601 }
1222 //fall down
1223
6/6
✓ Branch 0 taken 27192563 times.
✓ Branch 1 taken 10789759 times.
✓ Branch 2 taken 10519496 times.
✓ Branch 3 taken 27462826 times.
✓ Branch 4 taken 511263 times.
✓ Branch 5 taken 10008233 times.
37982322 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1224 {
1225
2/2
✓ Branch 0 taken 387698 times.
✓ Branch 1 taken 9620535 times.
10008233 if(isSideViewGravity())
1226 {
1227
1/2
✓ Branch 0 taken 387698 times.
✗ Branch 1 not taken.
387698 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1228 {
1229
2/2
✓ Branch 0 taken 230320 times.
✓ Branch 1 taken 157378 times.
387698 if(!isOnSideviewPlatform())
1230 {
1231 157378 bool willHitSVPlatform = false;
1232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH)?hit_width:16;
1233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT)?hit_height:16;
1234
2/2
✓ Branch 0 taken 157378 times.
✓ Branch 1 taken 157378 times.
314756 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1235 {
1236
5/8
✓ Branch 0 taken 23519 times.
✓ Branch 1 taken 133859 times.
✓ Branch 2 taken 23519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23519 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 157378 times.
✗ Branch 7 not taken.
157378 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1237 {
1238 willHitSVPlatform = true;
1239 break;
1240 }
1241 157378 }
1242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 if(willHitSVPlatform)
1243 {
1244 y+=fall/100;
1245 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1246 do_fix(y, 16); //Fix to top of SV Ladder
1247 fall = 0;
1248 }
1249 else
1250 {
1251 157378 y+=fall/100;
1252
2/2
✓ Branch 0 taken 17812 times.
✓ Branch 1 taken 139566 times.
157378 if(fall <= (int32_t)zinit.terminalv)
1253 139566 fall += (zinit.gravity/100);
1254 }
1255 157378 }
1256 else
1257 {
1258
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 230043 times.
230320 if(fall!=0) // Only fix pos once
1259 {
1260 //y-=(int32_t)y%8; // Fix position
1261 277 do_fix(y, 8); //Fix position
1262 277 }
1263
1264 230320 fall = 0;
1265 }
1266 387698 }
1267 else
1268 {
1269 if(isOnSideviewPlatform())
1270 fall = 0;
1271 else
1272 {
1273 zfix fall_amnt = fall/100;
1274 bool hit = false;
1275 while(fall_amnt >= 1)
1276 {
1277 --fall_amnt;
1278 ++y;
1279 if(isOnSideviewPlatform())
1280 {
1281 y = y.getInt();
1282 fall_amnt = 0;
1283 hit = true;
1284 break;
1285 }
1286 }
1287 if(fall_amnt > 0)
1288 y += fall_amnt;
1289 if(fall_amnt < 0)
1290 {
1291 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1292 hit = true;
1293 }
1294 if(hit)
1295 fall = 0;
1296 else if(fall <= (int32_t)zinit.terminalv)
1297 fall += (zinit.gravity/100);
1298 }
1299 }
1300 387698 }
1301 else
1302 {
1303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9620535 times.
9620535 if (!(moveflags & move_no_fake_z))
1304 {
1305
2/2
✓ Branch 0 taken 5065733 times.
✓ Branch 1 taken 4554802 times.
9620535 if(fakefall!=0)
1306 4554802 fakez-=(fakefall/100);
1307
1308
2/2
✓ Branch 0 taken 4554802 times.
✓ Branch 1 taken 5065733 times.
9620535 if(fakez<0)
1309 4554802 fakez = fakefall = 0;
1310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5065733 times.
5065733 else if(fakefall <= (int32_t)zinit.terminalv)
1311 5065733 fakefall += (zinit.gravity/100);
1312
1313
5/6
✓ Branch 0 taken 9620535 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5065733 times.
✓ Branch 3 taken 4554802 times.
✓ Branch 4 taken 4569045 times.
✓ Branch 5 taken 496688 times.
9620535 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1314 9620535 }
1315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9620535 times.
9620535 if (!(moveflags & move_no_real_z))
1316 {
1317
2/2
✓ Branch 0 taken 5486574 times.
✓ Branch 1 taken 4133961 times.
9620535 if(fall!=0)
1318 4133961 z-=(fall/100);
1319
1320
2/2
✓ Branch 0 taken 4119389 times.
✓ Branch 1 taken 5501146 times.
9620535 if(z<0)
1321 4119389 z = fall = 0;
1322
2/2
✓ Branch 0 taken 10057 times.
✓ Branch 1 taken 5491089 times.
5501146 else if(fall <= (int32_t)zinit.terminalv)
1323 5491089 fall += (zinit.gravity/100);
1324
1325
6/6
✓ Branch 0 taken 9578321 times.
✓ Branch 1 taken 42214 times.
✓ Branch 2 taken 5458932 times.
✓ Branch 3 taken 4119389 times.
✓ Branch 4 taken 4965379 times.
✓ Branch 5 taken 493553 times.
9620535 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1326 9620535 }
1327
1328 }
1329 10008233 }
1330
4/4
✓ Branch 0 taken 37466855 times.
✓ Branch 1 taken 515467 times.
✓ Branch 2 taken 9199938 times.
✓ Branch 3 taken 28266917 times.
37982322 if(!isSideViewGravity() && (moveflags & move_can_pitfall))
1331 {
1332
8/10
✓ Branch 0 taken 9173418 times.
✓ Branch 1 taken 26520 times.
✓ Branch 2 taken 9133760 times.
✓ Branch 3 taken 39658 times.
✓ Branch 4 taken 9133760 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9173418 times.
✓ Branch 8 taken 9133760 times.
✓ Branch 9 taken 9133760 times.
9199938 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1333 {
1334 9133760 fallCombo = check_pits();
1335 9133760 }
1336 27467458 }
1337
4/4
✓ Branch 0 taken 37466855 times.
✓ Branch 1 taken 18782987 times.
✓ Branch 2 taken 146897 times.
✓ Branch 3 taken 37319958 times.
56249842 if(!isSideViewGravity() && (moveflags & move_can_waterdrown))
1338 {
1339
8/10
✓ Branch 0 taken 142951 times.
✓ Branch 1 taken 3946 times.
✓ Branch 2 taken 141898 times.
✓ Branch 3 taken 1053 times.
✓ Branch 4 taken 141898 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 142951 times.
✓ Branch 8 taken 141898 times.
✓ Branch 9 taken 141898 times.
146897 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1340 {
1341 141898 drownCombo = check_water();
1342 141898 }
1343 430693 }
1344
1345 56533638 runKnockback(); //scripted knockback handling
1346
1347 // clk is incremented here
1348
2/2
✓ Branch 0 taken 54224117 times.
✓ Branch 1 taken 2309521 times.
56533638 if(++clk >= frate)
1349 2309521 clk=0;
1350
1351 // hit and death handling
1352
2/2
✓ Branch 0 taken 1249500 times.
✓ Branch 1 taken 55284138 times.
56533638 if(hclk>0)
1353 1249500 --hclk;
1354
1355
2/2
✓ Branch 0 taken 676245 times.
✓ Branch 1 taken 55857393 times.
56533638 if(stunclk>0)
1356 676245 --stunclk;
1357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56533638 times.
56533638 if ( frozenclock > 0 )
1358 --frozenclock;
1359
1360
5/6
✓ Branch 0 taken 14876 times.
✓ Branch 1 taken 56518762 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 14752 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 124 times.
56533638 if(ceiling && z <= 0 && fakez <= 0)
1361 124 ceiling = false;
1362
1363 56533638 try_death();
1364
1365 56533638 scored=false;
1366
1367 56533638 ++c_clk;
1368
1369 //Run its script
1370
2/2
✓ Branch 0 taken 18576133 times.
✓ Branch 1 taken 37957505 times.
56533638 if (!didScriptThisFrame)
1371 {
1372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37957505 times.
37957505 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1373 {
1374 return 0; //Avoid NULLPO if this object deleted itself
1375 }
1376 37957505 }
1377
1378 // returns true when enemy is defeated
1379 56533638 return Dead(index);
1380 56536261 }
1381
1382 38734536 bool enemy::setSolid(bool set)
1383 {
1384
1/2
✓ Branch 0 taken 38734536 times.
✗ Branch 1 not taken.
38734536 bool actual = set && !isSubmerged();
1385 38734536 bool ret = solid_object::setSolid(actual);
1386 38734536 solid = set;
1387 38734536 return ret;
1388 }
1389 void enemy::doContactDamage(int32_t hdir)
1390 {
1391 Hero.hithero(guys.find(this), hdir);
1392 }
1393
1394 22405 void enemy::solid_push(solid_object *obj)
1395 {
1396
1/2
✓ Branch 0 taken 22405 times.
✗ Branch 1 not taken.
22405 if(obj == this) return; //can't push self
1397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22405 times.
22405 if(moveflags&move_not_pushable) return; //not pushable
1398 22405 zfix dx, dy;
1399 22405 int32_t hdir = -1;
1400 22405 solid_push_int(obj,dx,dy,hdir,true);
1401
1402
4/4
✓ Branch 0 taken 22292 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 22142 times.
22405 if(!dx && !dy) return;
1403
1404 263 bool t = obj->getTempNonsolid();
1405 263 obj->setTempNonsolid(true);
1406
1407 263 int32_t ydir = dy > 0 ? down : up;
1408 263 int32_t xdir = dx > 0 ? right : left;
1409
1410 263 auto special = isflier(id) ? spw_floater : spw_none;
1411
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 7 times.
263 if(!movexy(dx,dy,special,true,true))
1412 {
1413 //Crushed?
1414 7 }
1415
1416 263 obj->setTempNonsolid(t);
1417 22405 }
1418 22405 bool enemy::is_unpushable() const
1419 {
1420 22405 return isSubmerged();
1421 }
1422 22087 bool enemy::sideview_mode() const
1423 {
1424
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22087 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1425 }
1426
1427 3234 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1428 {
1429 3234 int32_t yg = (special==spw_floater)?8:0;
1430 3234 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1431
1432
8/10
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2368 times.
✓ Branch 9 taken 3238 times.
3234 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1433 4732 return true;
1434
1435 3238 bool isInDungeon = isdungeon(screen_spawned);
1436
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3238 if(isInDungeon || special==spw_wizzrobe)
1437 {
1438
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2976 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1439 1199 return true;
1440
1441
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1442
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1443 return true;
1444 595 }
1445
1446
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1447 {
1448
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1449
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1450 return true;
1451 62 }
1452
1453
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1454 {
1455 case spw_clipbottomright:
1456 if(dy>=128 || dx>=208) return true;
1457 break;
1458 case spw_clipright:
1459 break; //if(x>=208) return true; break;
1460
1461 case spw_wizzrobe: // fall through
1462 case spw_floater: // Special case for fliers and wizzrobes - hack!
1463 {
1464
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1465 {
1466
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1467
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1468 595 }
1469 857 return false;
1470 }
1471 }
1472
1473 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1474 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1475
1476 if(special==spw_water)
1477 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1478
1479 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1480 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1481 870 }
1482
1483 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1484 {
1485 6575 bool kb = false;
1486 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1487
1488
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1489 return true;
1490
1491
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon(screen_spawned))
1492 {
1493
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=world_h-32))
1494 return true;
1495
1496
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=world_w-32))
1497 return true;
1498 1513 }
1499
1500
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1501 {
1502
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1503
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1504 return true;
1505 6575 }
1506
1507
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1508 {
1509
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1511 }
1512 else
1513 {
1514
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1515
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1516
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1518 }
1519 6575 }
1520
1521 // returns true if cannot walk
1522 32505056 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1523 {
1524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32505056 times.
32505056 if(moveflags & move_new_movement)
1525 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1526 32505056 int32_t yg = (special==spw_floater)?8:0;
1527 32505056 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1528
2/2
✓ Branch 0 taken 3724350 times.
✓ Branch 1 taken 28780706 times.
32505056 switch(dir)
1529 {
1530 case l_down:
1531 case r_down:
1532 case down:
1533 case 11: //r_down
1534 case 12: //down
1535 case 13: //l_down
1536 {
1537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3724350 times.
3724350 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1538 {
1539
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3724342 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3724350 if ( SIZEflags&OVERRIDE_HIT_HEIGHT && !isflier(id) )
1540 {
1541 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1542
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1543 8 }
1544 3724350 }
1545 3724350 break;
1546 }
1547 }
1548
2/2
✓ Branch 0 taken 3726312 times.
✓ Branch 1 taken 28778744 times.
32505056 switch(dir)
1549 {
1550 case r_up:
1551 case r_down:
1552 case right:
1553 case 9: //r_up
1554 case 10: //right
1555 case 11: //r_down
1556 {
1557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3726312 times.
3726312 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1558 {
1559
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3726309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3726312 if ( SIZEflags&OVERRIDE_HIT_WIDTH && !isflier(id) )
1560 {
1561 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1562
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dx += zc_max(hit_width-16,0);
1563 3 }
1564 3726312 }
1565 3726312 break;
1566 }
1567 }
1568 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
1569
1570
10/10
✓ Branch 0 taken 22401419 times.
✓ Branch 1 taken 10103637 times.
✓ Branch 2 taken 8754240 times.
✓ Branch 3 taken 1349397 times.
✓ Branch 4 taken 10066461 times.
✓ Branch 5 taken 37176 times.
✓ Branch 6 taken 10043258 times.
✓ Branch 7 taken 23203 times.
✓ Branch 8 taken 22454411 times.
✓ Branch 9 taken 32497669 times.
32505056 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1571 44916209 return true;
1572
1573 32497669 bool isInDungeon = isdungeon(screen_spawned);
1574
4/4
✓ Branch 0 taken 3976536 times.
✓ Branch 1 taken 28521133 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 3964780 times.
32497669 if(isInDungeon || special==spw_wizzrobe)
1575 {
1576
8/8
✓ Branch 0 taken 5892066 times.
✓ Branch 1 taken 22640823 times.
✓ Branch 2 taken 5667599 times.
✓ Branch 3 taken 224467 times.
✓ Branch 4 taken 5820182 times.
✓ Branch 5 taken 17045108 times.
✓ Branch 6 taken 5819995 times.
✓ Branch 7 taken 187 times.
28532889 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=world_h-32 && dy>=world_h-32))
1577 11487594 return true;
1578
1579
8/8
✓ Branch 0 taken 5739703 times.
✓ Branch 1 taken 11305592 times.
✓ Branch 2 taken 5573250 times.
✓ Branch 3 taken 166453 times.
✓ Branch 4 taken 5688164 times.
✓ Branch 5 taken 5783881 times.
✓ Branch 6 taken 5687210 times.
✓ Branch 7 taken 954 times.
17045295 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<world_w-32 && dx>=world_w-32))
1580
2/2
✓ Branch 0 taken 113866 times.
✓ Branch 1 taken 94 times.
11260460 if(special!=spw_door) // walk in door way
1581 113866 return true;
1582 5784929 }
1583
1584
6/6
✓ Branch 0 taken 3102199 times.
✓ Branch 1 taken 6647510 times.
✓ Branch 2 taken 750571 times.
✓ Branch 3 taken 2351628 times.
✓ Branch 4 taken 51230 times.
✓ Branch 5 taken 699341 times.
9749709 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1585 {
1586
4/4
✓ Branch 0 taken 3044552 times.
✓ Branch 1 taken 6417 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 3043600 times.
6094619 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1587
4/4
✓ Branch 0 taken 3044369 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 3043650 times.
✓ Branch 3 taken 719 times.
3044552 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1588 7369 return true;
1589 3043600 }
1590
1591
4/4
✓ Branch 0 taken 7555697 times.
✓ Branch 1 taken 2180389 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5281 times.
9742340 switch(special)
1592 {
1593 case spw_clipbottomright:
1594
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=world_h-48 || dx>=world_w-48) return true;
1595 707 break;
1596 case spw_clipright:
1597 5281 break; //if(input_x>=208) return true; break;
1598
1599 case spw_wizzrobe: // fall through
1600 case spw_floater: // Special case for fliers and wizzrobes - hack!
1601 {
1602
2/2
✓ Branch 0 taken 2914018 times.
✓ Branch 1 taken 4641679 times.
7555697 if(isInDungeon)
1603 {
1604
3/4
✓ Branch 0 taken 4641667 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641667 times.
4641679 if(dy < 32-yg || dy >= world_h-32) return true;
1605
4/4
✓ Branch 0 taken 4639555 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639539 times.
4641667 if(dx < 32 || dx >= world_w-32) return true;
1606 4639539 }
1607 7553557 return false;
1608 }
1609 }
1610
1611 2186377 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1612
2/2
✓ Branch 0 taken 486589 times.
✓ Branch 1 taken 1699788 times.
2186377 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1613
1614
2/2
✓ Branch 0 taken 414677 times.
✓ Branch 1 taken 1771700 times.
2186377 if(special==spw_water)
1615
2/2
✓ Branch 0 taken 16749 times.
✓ Branch 1 taken 397928 times.
414677 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1616
1617
2/2
✓ Branch 0 taken 1711796 times.
✓ Branch 1 taken 59904 times.
1771700 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1618 {
1619
4/4
✓ Branch 0 taken 1228137 times.
✓ Branch 1 taken 483659 times.
✓ Branch 2 taken 1218100 times.
✓ Branch 3 taken 10037 times.
2929896 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1620
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1203520 times.
1218100 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1621 }
1622 else
1623 {
1624
4/4
✓ Branch 0 taken 42909 times.
✓ Branch 1 taken 16995 times.
✓ Branch 2 taken 42645 times.
✓ Branch 3 taken 264 times.
102549 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1625
3/4
✓ Branch 0 taken 42282 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 42282 times.
✗ Branch 3 not taken.
42645 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1626
4/4
✓ Branch 0 taken 37047 times.
✓ Branch 1 taken 5235 times.
✓ Branch 2 taken 37032 times.
✓ Branch 3 taken 15 times.
42282 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1627
2/2
✓ Branch 0 taken 36729 times.
✓ Branch 1 taken 303 times.
37032 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1628 }
1629 10129342 }
1630
1631 496901 bool enemy::isOnSideviewPlatform()
1632 {
1633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
1634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1635
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
496901 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1636 return false;
1637
5/6
✓ Branch 0 taken 11630 times.
✓ Branch 1 taken 485271 times.
✓ Branch 2 taken 422 times.
✓ Branch 3 taken 11208 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 422 times.
496901 if(y + usehei >= world_h && cur_screen>=0x70 && !(get_scr_for_world_xy(x, y)->flags2&wfDOWN)) return true; //Bottom of the map
1638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496479 times.
496479 if(check_slope(x, y+1, usewid, usehei)) return true;
1639
2/2
✓ Branch 0 taken 496479 times.
✓ Branch 1 taken 215641 times.
712120 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1640 {
1641
2/2
✓ Branch 0 taken 215641 times.
✓ Branch 1 taken 280838 times.
496479 if(_walkflag(nx,y+usehei,1)) return true;
1642
3/4
✓ Branch 0 taken 215641 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151313 times.
✓ Branch 3 taken 64328 times.
215641 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64328 times.
64328 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1644 64328 }
1645 215641 return false;
1646 496901 }
1647
1648 // Stops playing the given sound only if there are no enemies left to play it
1649 768396 void enemy::stop_bgsfx(int32_t index)
1650 {
1651
2/2
✓ Branch 0 taken 753286 times.
✓ Branch 1 taken 15110 times.
768396 if(bgsfx<=0)
1652 753286 return;
1653
1654 // Look for other enemies with the same bgsfx
1655
2/2
✓ Branch 0 taken 52994 times.
✓ Branch 1 taken 8806 times.
61800 for(int32_t i=0; i<guys.Count(); i++)
1656 {
1657
4/4
✓ Branch 0 taken 41902 times.
✓ Branch 1 taken 11092 times.
✓ Branch 2 taken 6304 times.
✓ Branch 3 taken 35598 times.
52994 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1658 6304 return;
1659 46690 }
1660
1661 8806 stop_sfx(bgsfx);
1662 768396 }
1663
1664
1665 // to allow for different sfx on defeating enemy
1666 40351 void enemy::death_sfx()
1667 {
1668
2/2
✓ Branch 0 taken 40066 times.
✓ Branch 1 taken 285 times.
40351 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
1669 40351 }
1670
1671 void enemy::move(zfix dx,zfix dy)
1672 {
1673 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1674 {
1675 x+=dx;
1676 y+=dy;
1677 }
1678 }
1679
1680 18372006 void enemy::move(zfix s)
1681 {
1682
9/10
✓ Branch 0 taken 18371967 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 109109 times.
✓ Branch 3 taken 18262858 times.
✓ Branch 4 taken 58221 times.
✓ Branch 5 taken 50888 times.
✓ Branch 6 taken 1005 times.
✓ Branch 7 taken 57216 times.
✓ Branch 8 taken 1005 times.
✗ Branch 9 not taken.
18372006 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1683 {
1684 18370962 sprite::move(s);
1685 18370962 }
1686 18372006 }
1687
1688 43831 void enemy::leave_item()
1689 {
1690 43831 int32_t drop_item = select_dropitem(item_set, x, y);
1691 43831 int32_t thedropset = item_set;
1692
1693 43831 std::vector<int32_t> &ev = FFCore.eventData;
1694 43831 ev.clear();
1695 43831 ev.push_back(getUID());
1696 43831 ev.push_back(drop_item*10000);
1697 43831 ev.push_back(thedropset*10000);
1698
1699 43831 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1700 43831 drop_item = vbound(ev[1] / 10000,-2,255);
1701 43831 thedropset = ev[2] / 10000;
1702 43831 ev.clear();
1703
1/2
✓ Branch 0 taken 43831 times.
✗ Branch 1 not taken.
43831 if(drop_item == -2)
1704 {
1705 drop_item = select_dropitem(thedropset,x,y);
1706 }
1707
1708
6/6
✓ Branch 0 taken 16542 times.
✓ Branch 1 taken 27289 times.
✓ Branch 2 taken 917 times.
✓ Branch 3 taken 15625 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 748 times.
43831 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1709 {
1710 item* itm;
1711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16373 times.
16373 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1712 {
1713 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1714 }
1715 else
1716 {
1717
8/14
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 14653 times.
✓ Branch 2 taken 1720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1720 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1720 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1720 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1720 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1720 times.
✗ Branch 13 not taken.
16373 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1718
4/8
✓ Branch 0 taken 14653 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14653 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14653 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14653 times.
✗ Branch 7 not taken.
14653 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1719 }
1720 16373 itm->from_dropset = thedropset;
1721 16373 add_item_for_screen(screen_spawned, itm);
1722
1723 16373 ev.push_back(getUID());
1724 16373 ev.push_back(itm->getUID());
1725
1726 16373 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1727 16373 ev.clear();
1728 16373 }
1729 43831 }
1730
1731 // auomatically kill off enemy (for rooms with ringleaders)
1732 411 void enemy::kickbucket()
1733 {
1734
3/4
✓ Branch 0 taken 379 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 379 times.
✗ Branch 3 not taken.
411 if(!superman && !(flags&guy_ignore_kill_all))
1735 379 hp=-1000; // don't call death_sfx()
1736 411 }
1737
1738 21250 bool enemy::isSubmerged() const
1739 {
1740 21250 return submerged;
1741 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1742 }
1743
1744 20952 void enemy::FireBreath(bool seekhero)
1745 {
1746
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1747 return;
1748
1749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1750 {
1751 dmisc1 = e1tEACHTILE;
1752 FireWeapon();
1753 return;
1754 }
1755
1756 20952 float fire_angle=0.0;
1757 20952 int32_t wx=0, wy=0, wdir=dir, xoff=0, yoff=0;
1758
1759
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1760 {
1761 xoff += hxofs;
1762 if (weapoverrideFLAGS & OVERRIDE_HIT_WIDTH)
1763 xoff += (hit_width / 2) - (weap_tilew * 8);
1764 else
1765 xoff += (hit_width / 2) - 8;
1766 }
1767
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1768 {
1769 yoff += hyofs;
1770 if (weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT)
1771 yoff += (hit_height / 2) - (weap_tileh * 8);
1772 else
1773 yoff += (hit_height / 2) - 8;
1774 }
1775
1776
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1777 {
1778
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1779 {
1780 case down:
1781 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1782 3079 wx=x;
1783 3079 wy=y+8;
1784 3079 break;
1785
1786 case -1:
1787 case up:
1788 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1789 3297 wx=x;
1790 3297 wy=y-8;
1791 3297 break;
1792
1793 case left:
1794 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1795 5287 wx=x-8;
1796 5287 wy=y;
1797 5287 break;
1798
1799 case right:
1800 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1801 4208 wx=x+8;
1802 4208 wy=y;
1803 4208 break;
1804 }
1805
1806
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1807 {
1808
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1814
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1815
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1816 15735 }
1817 15871 }
1818 else
1819 {
1820 5081 wx = x;
1821 5081 wy = y;
1822 }
1823
1824
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx+xoff,wy+yoff,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1825 20952 sfx(wpnsfx(wpn),pan(int32_t(x)));
1826
1827 20952 int32_t i=Ewpns.Count()-1;
1828 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1829 20952 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1830
1831
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1832 {
1833 7957 ew->angular=true;
1834 7957 ew->angle=fire_angle;
1835 7957 }
1836
1837
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1838 {
1839 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1841 20359 }
1842
1843
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1844 {
1845 766199 Ewpns.swap(j,j-1);
1846 766199 }
1847 20952 }
1848
1849 44659 void enemy::FireWeapon()
1850 {
1851 /*
1852 * Type:
1853 * 0x01: Boss fireball
1854 * 0x02: Seeks Hero
1855 * 0x04: Fast projectile
1856 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1857 */
1858
1859
2/2
✓ Branch 0 taken 44528 times.
✓ Branch 1 taken 131 times.
44659 if (wpn < 1) return;
1860
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 44528 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
44528 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1861 return;
1862
1863
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44528 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44528 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1864 dmisc1 = e1tEACHTILE;
1865
1866 44528 int32_t xoff = 0;
1867 44528 int32_t yoff = 0;
1868
1/2
✓ Branch 0 taken 44528 times.
✗ Branch 1 not taken.
44528 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1869 {
1870 xoff += hxofs;
1871 if (weapoverrideFLAGS & OVERRIDE_HIT_WIDTH)
1872 xoff += (hit_width / 2) - (weap_tilew * 8);
1873 else
1874 xoff += (hit_width / 2) - 8;
1875 }
1876
1/2
✓ Branch 0 taken 44528 times.
✗ Branch 1 not taken.
44528 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1877 {
1878 yoff += hyofs;
1879 if (weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT)
1880 yoff += (hit_height / 2) - (weap_tileh * 8);
1881 else
1882 yoff += (hit_height / 2) - 8;
1883 }
1884
1885 // TODO(crash): check that .add succeeds.
1886
1887
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 41529 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 416 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
44528 switch(dmisc1)
1888 {
1889 case e1t5SHOTS: //BS-Aquamentus
1890 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1891 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1892 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1893 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1894
1895 [[fallthrough]];
1896 case e1t3SHOTSFAST:
1897 case e1t3SHOTS: //Aquamentus
1898
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1899 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1900
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1901 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1902
1903 [[fallthrough]];
1904 default:
1905
12/20
✓ Branch 0 taken 42175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42175 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42175 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42175 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 42175 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 42170 times.
✓ Branch 12 taken 42175 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 23937 times.
✓ Branch 16 taken 42175 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 42175 times.
✗ Branch 19 not taken.
42175 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1906 42175 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1907 42175 sfx(wpnsfx(wpn),pan(int32_t(x)));
1908 42175 break;
1909
1910 case e1tSLANT:
1911 {
1912 416 int32_t slant = 0;
1913
1914
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 161 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
416 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1915 246 slant = left;
1916
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1917 117 slant = right;
1918
1919
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1920 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1921 330 sfx(wpnsfx(wpn),pan(int32_t(x)));
1922 330 break;
1923 }
1924
1925 case e1t8SHOTS: //Fire Wizzrobe
1926
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1927 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1928 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1929
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1930 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1931 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1932
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1933 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1934 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1935
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1936 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1937 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1938
1939 [[fallthrough]];
1940 case e1t4SHOTS: //Stalfos 3
1941
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1942 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1943 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1944
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1945 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1946 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1947
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1948 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1949 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1950
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1951 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1952 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1953 1937 sfx(wpnsfx(wpn),pan(int32_t(x)));
1954 1937 break;
1955
1956 case e1tSUMMON: // Bat Wizzrobe
1957 {
1958 if(dmisc4==0) break; // Summon 0
1959
1960 int32_t bc=0;
1961
1962 for(int32_t gc=0; gc<guys.Count(); gc++)
1963 {
1964 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1965 {
1966 ++bc;
1967 }
1968 }
1969
1970 if(bc<=40) // Not too many enemies
1971 {
1972 int32_t kids = guys.Count();
1973 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1974
1975 for(int32_t i=0; i<bats; i++)
1976 {
1977 if(addchild(screen_spawned,x,y,dmisc3,-10, this->getUID()))
1978 {
1979 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1980 }
1981 }
1982
1983 sfx(firesfx, pan(int32_t(x)));
1984 }
1985
1986 break;
1987 }
1988
1989 case e1tSUMMONLAYER: // Summoner
1990 {
1991 if(count_layer_enemies(screen_spawned)==0)
1992 {
1993 break;
1994 }
1995
1996 int32_t kids = guys.Count();
1997
1998 if(kids<40)
1999 {
2000 int32_t newguys=(zc_oldrand()%3)+1;
2001 bool summoned=false;
2002
2003 for(int32_t i=0; i<newguys; i++)
2004 {
2005 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
2006 int32_t x2=0;
2007 int32_t y2=0;
2008
2009 for(int32_t k=0; k<20; ++k)
2010 {
2011 x2=16*((zc_oldrand()%12)+2);
2012 y2=16*((zc_oldrand()%7)+2);
2013
2014 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
2015 {
2016 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->getUID()))
2017 {
2018 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2019 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
2020 {
2021 ((enemy*)guys.spr(kids+i))->fakez = 64;
2022 ((enemy*)guys.spr(kids+i))->z = 0;
2023 }
2024 }
2025
2026 summoned=true;
2027 break;
2028 }
2029 }
2030 }
2031
2032 if(summoned)
2033 {
2034 sfx(firesfx, pan(int32_t(x)));
2035 }
2036 }
2037
2038 break;
2039 }
2040 }
2041 44573 }
2042
2043
2044 // Hit the shield(s)?
2045 // Apparently, this function is only used for hookshots...
2046 2767 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2047 {
2048
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1791 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2767 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
2049 834 return false;
2050
2051 1933 bool ret = false;
2052
2053 // TODO: There must be some bitwise operations that can simplify this...
2054
9/12
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 726 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1933 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2055
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 811 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1207 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2056
2057
11/14
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 840 times.
1933 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2058
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2059
2060 1933 return ret;
2061 2767 }
2062
2063
2064 //! Weapon Editor for 2.6
2065 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2066
2067
2068 //converts a wqeapon ID to its defence index.
2069 127292 int32_t weaponToDefence(int32_t wid)
2070 {
2071
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 64771 times.
✓ Branch 2 taken 9438 times.
✓ Branch 3 taken 25035 times.
✓ Branch 4 taken 4207 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3160 times.
✓ Branch 9 taken 9836 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1250 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2054 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 28 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
127292 switch(wid)
2072 {
2073 case wNone: return -1;
2074 64771 case wSword: return edefSWORD;
2075 9438 case wBeam: return edefBEAM;
2076 25035 case wBrang: return edefBRANG;
2077 4207 case wBomb: return edefBOMB;
2078 37 case wSBomb: return edefSBOMB;
2079 48 case wLitBomb: return edefBOMB;
2080 case wLitSBomb: return edefSBOMB;
2081 3160 case wArrow: return edefARROW;
2082 9836 case wFire: return edefFIRE;
2083 case wWhistle:
2084 {
2085 return edefWhistle;
2086 }
2087 case wBait: return edefBAIT;
2088 269 case wWand: return edefWAND;
2089 1250 case wMagic: return edefMAGIC;
2090 case wCatching: return -1;
2091 case wWind: return edefWIND;
2092 512 case wRefMagic: return edefREFMAGIC;
2093 1459 case wRefFireball: return edefREFBALL;
2094 case wRefRock: return edefREFROCK;
2095 2054 case wHammer: return edefHAMMER;
2096 2767 case wHookshot: return edefHOOKSHOT;
2097 610 case wHSHandle: return edefHOOKSHOT;
2098 case wHSChain: return edefHOOKSHOT;
2099 240 case wSSparkle: return edefSPARKLE;
2100 469 case wFSparkle: return edefSPARKLE;
2101 case wSmack: return -1; // is this the candle object?
2102 case wPhantom: return -1; //engine created visual effects.
2103 case wCByrna: return edefBYRNA;
2104 19 case wRefBeam: return edefREFBEAM;
2105 case wStomp: return edefSTOMP;
2106 28 case wScript1: return edefSCRIPT01;
2107 case wScript2: return edefSCRIPT02;
2108 12 case wScript3: return edefSCRIPT03;
2109 77 case wScript4: return edefSCRIPT04;
2110 case wScript5: return edefSCRIPT05;
2111 case wScript6: return edefSCRIPT06;
2112 case wScript7: return edefSCRIPT07;
2113 case wScript8: return edefSCRIPT08;
2114 case wScript9: return edefSCRIPT09;
2115 993 case wScript10: return edefSCRIPT10;
2116 case wIce: return edefICE;
2117 case wSound: return edefSONIC;
2118 1 case wThrown: return edefTHROWN;
2119 case wRefArrow: return edefREFARROW;
2120 case wRefFire: return edefREFFIRE;
2121 case wRefFire2: return edefREFFIRE2;
2122 //case wPot: return edefPOT;
2123 // case wLitZap: return edefELECTRIC;
2124 // case wZ3Sword: return edefZ3SWORD;
2125 // case wLASWord: return edefLASWORD;
2126 // case wSpinAttk: return edefSPINATTK;
2127 // case wShield: return edefSHIELD;
2128 // case wTrowel: return edefTROWEL;
2129
2130 default: return -1;
2131 }
2132 127292 }
2133
2134 127292 int32_t getDefType(weapon *w)
2135 {
2136 127292 int32_t id = getWeaponID(w);
2137 127292 int32_t edef = weaponToDefence(id);
2138
2/2
✓ Branch 0 taken 123915 times.
✓ Branch 1 taken 3377 times.
127292 if(edef == edefHOOKSHOT)
2139 {
2140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2141 return edefSwitchHook;
2142 3377 }
2143 127292 return edef;
2144 127292 }
2145
2146 226782 int32_t getWeaponID(weapon *w)
2147 {
2148 226782 int32_t usewpn = w->useweapon;
2149
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 226552 times.
226782 return (usewpn > 0) ? usewpn : w->id;
2150 }
2151
2152 127292 int32_t enemy::resolveEnemyDefence(weapon *w)
2153 {
2154 //sword edef is 9, but we're reading it at 0
2155 //,
2156 127292 int32_t weapondef = 0;
2157 127292 int32_t wdeftype = getDefType(w);
2158 127292 int32_t usedef = w->usedefence;
2159
2160
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 127292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
127292 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2161 {
2162 weapondef = usedef*-1;
2163 }
2164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127292 times.
127292 else if(unsigned(wdeftype) < edefLAST255)
2165 {
2166 127292 weapondef = wdeftype;
2167 127292 }
2168 127292 return weapondef;
2169 }
2170
2171 137859 byte get_def_ignrflag(int32_t edef)
2172 {
2173
3/3
✓ Branch 0 taken 114889 times.
✓ Branch 1 taken 3683 times.
✓ Branch 2 taken 19287 times.
137859 switch(edef)
2174 {
2175 case edIGNORE:
2176 case edIGNOREL1:
2177 case edSTUNORIGNORE:
2178 19287 return WPNUNB_IGNR;
2179 case edSTUNORCHINK:
2180 case edCHINK:
2181 case edCHINKL1:
2182 case edCHINKL2:
2183 case edCHINKL4:
2184 case edCHINKL6:
2185 case edCHINKL8:
2186 case edCHINKL10:
2187 case edLEVELCHINK2:
2188 case edLEVELCHINK3:
2189 case edLEVELCHINK4:
2190 case edLEVELCHINK5:
2191 3683 return WPNUNB_BLOCK;
2192 }
2193 114889 return 0;
2194 137859 }
2195
2196 137859 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2197 {
2198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137859 times.
137859 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2199 switch(edef)
2200 {
2201 case edIGNORE:
2202 case edIGNOREL1:
2203 case edCHINK:
2204 case edCHINKL1:
2205 case edCHINKL2:
2206 case edCHINKL4:
2207 case edCHINKL6:
2208 case edCHINKL8:
2209 case edCHINKL10:
2210 case edLEVELCHINK2:
2211 case edLEVELCHINK3:
2212 case edLEVELCHINK4:
2213 case edLEVELCHINK5:
2214 return edNORMAL;
2215 case edSTUNORIGNORE:
2216 case edSTUNORCHINK:
2217 return edSTUNONLY;
2218 }
2219 return edef;
2220 137859 }
2221
2222 // Do we do damage?
2223 // 0: takehit returns 0
2224 // 1: takehit returns 1
2225 // -1: do damage
2226 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2227 126299 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2228 {
2229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126299 times.
126299 if(switch_hooked) return 0;
2230 126299 int32_t tempx = x;
2231 126299 int32_t tempy = y;
2232 126299 int32_t the_defence = 0;
2233
1/2
✓ Branch 0 taken 126299 times.
✗ Branch 1 not taken.
126299 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2234 {
2235 the_defence = edef*-1; //A specific defence type.
2236 }
2237 126299 else the_defence = defense[edef];
2238
2239 126299 the_defence = conv_edef_unblockable(the_defence, unblockable);
2240
2241
3/4
✓ Branch 0 taken 6623 times.
✓ Branch 1 taken 119676 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6623 times.
126299 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2242 {
2243
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6616 times.
✓ Branch 2 taken 7 times.
6623 switch(the_defence)
2244 {
2245 case edIGNORE:
2246 7 return 0;
2247 case edIGNOREL1:
2248 case edSTUNORIGNORE:
2249 if(*power <= 0)
2250 return 0;
2251 }
2252 6616 sfx(WAV_CHINK,pan(int32_t(x)));
2253 6616 return 1;
2254 }
2255
2256 119676 int32_t new_id = id;
2257 119676 int32_t effect_type = dmisc15;
2258 119676 int32_t delay_timer = 90;
2259 119676 enemy *gleeok = NULL;
2260 119676 enemy *ptra = NULL;
2261 119676 int32_t c = 0;
2262
2263
16/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1931 times.
✓ Branch 6 taken 1862 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 945 times.
✓ Branch 13 taken 17349 times.
✓ Branch 14 taken 883 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2175 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 105 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 93415 times.
119676 switch(the_defence)
2264 {
2265 case edREPLACE:
2266 {
2267 sclk = 0;
2268 if ( dmisc16 > 0 ) new_id = dmisc16;
2269 else new_id = id+1;
2270 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2271 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2272 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2273
2274 //Z_scripterrlog("new id is %d\n", new_id);
2275 switch(guysbuf[new_id&0xFFF].family)
2276 {
2277 //Fixme: possible enemy memory leak. (minor)
2278 case eeWALK:
2279 {
2280 enemy *e = new eStalfos(x,y,new_id,clk);
2281 guys.add(e);
2282 }
2283 break;
2284
2285 case eeLEV:
2286 {
2287 enemy *e = new eLeever(x,y,new_id,clk);
2288 guys.add(e);
2289 }
2290 break;
2291
2292 case eeTEK:
2293 {
2294 enemy *e = new eTektite(x,y,new_id,clk);
2295 guys.add(e);
2296 }
2297 break;
2298
2299 case eePEAHAT:
2300 {
2301 enemy *e = new ePeahat(x,y,new_id,clk);
2302 guys.add(e);
2303 }
2304 break;
2305
2306 case eeZORA:
2307 {
2308 enemy *e = new eZora(x,y,new_id,clk);
2309 guys.add(e);
2310 }
2311 break;
2312
2313 case eeGHINI:
2314 {
2315 enemy *e = new eGhini(x,y,new_id,clk);
2316 guys.add(e);
2317 }
2318 break;
2319
2320 case eeKEESE:
2321 {
2322 enemy *e = new eKeese(x,y,new_id,clk);
2323 guys.add(e);
2324 }
2325 break;
2326
2327 case eeWIZZ:
2328 {
2329 enemy *e = new eWizzrobe(x,y,new_id,clk);
2330 guys.add(e);
2331 }
2332 break;
2333
2334 case eePROJECTILE:
2335 {
2336 enemy *e = new eProjectile(x,y,new_id,clk);
2337 guys.add(e);
2338 }
2339 break;
2340
2341 case eeWALLM:
2342 {
2343 enemy *e = new eWallM(x,y,new_id,clk);
2344 guys.add(e);
2345 }
2346 break;
2347
2348 case eeAQUA:
2349 {
2350 enemy *e = new eAquamentus(x,y,new_id,clk);
2351 guys.add(e);
2352 e->x = x;
2353 e->y = y;
2354 }
2355 break;
2356
2357 case eeMOLD:
2358 {
2359 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2360 guys.add(e);
2361 e->x = x;
2362 e->y = y;
2363 }
2364 break;
2365
2366 case eeMANHAN:
2367 {
2368 enemy *e = new eManhandla(x,y,new_id,clk);
2369 guys.add(e);
2370 e->x = x;
2371 e->y = y;
2372 }
2373 break;
2374
2375 case eeGLEEOK:
2376 {
2377 *power = 0;
2378 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2379 guys.add(gleeok);
2380 // TODO(crash): check that .add succeeds.
2381 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2382 new_id &= 0xFFF;
2383 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2384 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2385 for(int32_t i=0; i<head_cnt; i++)
2386 {
2387 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2388 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2389 {
2390 al_trace("Gleeok head %d could not be created!\n",i+1);
2391
2392 for(int32_t j=0; j<i+1; j++)
2393 {
2394 guys.del(guys.Count()-1);
2395 }
2396
2397 break;
2398 }
2399 else
2400 {
2401 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2402 }
2403
2404 c-=guysbuf[new_id].attributes[3];
2405 }
2406 return 1;
2407 }
2408
2409 case eeGHOMA:
2410 {
2411 enemy *e = new eGohma(x,y,new_id,clk);
2412 guys.add(e);
2413 e->x = x;
2414 e->y = y;
2415 }
2416 break;
2417
2418 case eeLANM:
2419 {
2420 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2421 guys.add(e);
2422 e->x = x;
2423 e->y = y;
2424 }
2425 break;
2426
2427 case eeGANON:
2428 {
2429 enemy *e = new eGanon(x,y,new_id,clk);
2430 guys.add(e);
2431 e->x = x;
2432 e->y = y;
2433 }
2434 break;
2435
2436 case eeFAIRY:
2437 {
2438 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2439 guys.add(e);
2440 e->x = x;
2441 e->y = y;
2442 }
2443 break;
2444
2445 case eeFIRE:
2446 {
2447 enemy *e = new eFire(x,y,new_id,clk);
2448 guys.add(e);
2449 e->x = x;
2450 e->y = y;
2451 }
2452 break;
2453
2454 case eeOTHER:
2455 {
2456 enemy *e = new eOther(x,y,new_id,clk);
2457 guys.add(e);
2458 e->x = x;
2459 e->y = y;
2460 }
2461 break;
2462
2463 case eeSPINTILE:
2464 {
2465 enemy *e = new eSpinTile(x,y,new_id,clk);
2466 guys.add(e);
2467 e->x = x;
2468 e->y = y;
2469 }
2470 break;
2471
2472 // and these enemies use the misc10/misc2 value
2473 case eeROCK:
2474 {
2475 switch(guysbuf[new_id&0xFFF].attributes[9])
2476 {
2477 case 1:
2478 {
2479 enemy *e = new eBoulder(x,y,new_id,clk);
2480 guys.add(e);
2481 e->x = x;
2482 e->y = y;
2483 }
2484 break;
2485
2486 case 0:
2487 default:
2488 {
2489 enemy *e = new eRock(x,y,new_id,clk);
2490 guys.add(e);
2491 e->x = x;
2492 e->y = y;
2493 }
2494 break;
2495 }
2496
2497 break;
2498 }
2499
2500 case eeTRAP:
2501 {
2502 switch(guysbuf[new_id&0xFFF].attributes[1])
2503 {
2504 case 1:
2505 {
2506 enemy *e = new eTrap2(x,y,new_id,clk);
2507 guys.add(e);
2508 e->x = x;
2509 e->y = y;
2510 }
2511 break;
2512
2513 case 0:
2514 default:
2515 {
2516 enemy *e = new eTrap(x,y,new_id,clk);
2517 guys.add(e);
2518 e->x = x;
2519 e->y = y;
2520 }
2521 break;
2522 }
2523
2524 break;
2525 }
2526
2527 case eeDONGO:
2528 {
2529 switch(guysbuf[new_id&0xFFF].attributes[9])
2530 {
2531 case 1:
2532 {
2533 enemy *e = new eDodongo2(x,y,new_id,clk);
2534 guys.add(e);
2535 e->x = x;
2536 e->y = y;
2537 }
2538 break;
2539
2540 case 0:
2541 default:
2542 {
2543 enemy *e = new eDodongo(x,y,new_id,clk);
2544 guys.add(e);
2545 e->x = x;
2546 e->y = y;
2547 }
2548 break;
2549 }
2550
2551 break;
2552 }
2553
2554 case eeDIG:
2555 {
2556 switch(guysbuf[new_id&0xFFF].attributes[9])
2557 {
2558 case 1:
2559 {
2560 enemy *e = new eLilDig(x,y,new_id,clk);
2561 guys.add(e);
2562 e->x = x;
2563 e->y = y;
2564 }
2565 break;
2566
2567 case 0:
2568 default:
2569 {
2570 enemy *e = new eBigDig(x,y,new_id,clk);
2571 guys.add(e);
2572 e->x = x;
2573 e->y = y;
2574 }
2575 break;
2576 }
2577
2578 break;
2579 }
2580
2581 case eePATRA:
2582 {
2583 switch(guysbuf[new_id&0xFFF].attributes[9])
2584 {
2585 case 1:
2586 {
2587 if (get_qr(qr_HARDCODED_BS_PATRA))
2588 {
2589 enemy *e = new ePatraBS(x,y,new_id,clk);
2590 guys.add(e);
2591 e->x = x;
2592 e->y = y;
2593 break;
2594 }
2595 }
2596 [[fallthrough]];
2597 case 0:
2598 default:
2599 {
2600 enemy *e = new ePatra(x,y,new_id,clk);
2601 guys.add(e);
2602 e->x = x;
2603 e->y = y;
2604 }
2605 break;
2606 }
2607
2608 break;
2609 }
2610
2611 case eeGUY:
2612 {
2613 switch(guysbuf[new_id&0xFFF].attributes[9])
2614 {
2615 case 1:
2616 {
2617 enemy *e = new eTrigger(x,y,new_id,clk);
2618 guys.add(e);
2619 }
2620 break;
2621
2622 case 0:
2623 default:
2624 {
2625 enemy *e = new eNPC(x,y,new_id,clk);
2626 guys.add(e);
2627 }
2628 break;
2629 }
2630
2631 break;
2632 }
2633
2634 case eeSCRIPT01:
2635 case eeSCRIPT02:
2636 case eeSCRIPT03:
2637 case eeSCRIPT04:
2638 case eeSCRIPT05:
2639 case eeSCRIPT06:
2640 case eeSCRIPT07:
2641 case eeSCRIPT08:
2642 case eeSCRIPT09:
2643 case eeSCRIPT10:
2644 case eeSCRIPT11:
2645 case eeSCRIPT12:
2646 case eeSCRIPT13:
2647 case eeSCRIPT14:
2648 case eeSCRIPT15:
2649 case eeSCRIPT16:
2650 case eeSCRIPT17:
2651 case eeSCRIPT18:
2652 case eeSCRIPT19:
2653 case eeSCRIPT20:
2654 {
2655 enemy *e = new eScript(x,y,new_id,clk);
2656 guys.add(e);
2657 e->x = x;
2658 e->y = y;
2659 break;
2660 }
2661
2662
2663 case eeFFRIENDLY01:
2664 case eeFFRIENDLY02:
2665 case eeFFRIENDLY03:
2666 case eeFFRIENDLY04:
2667 case eeFFRIENDLY05:
2668 case eeFFRIENDLY06:
2669 case eeFFRIENDLY07:
2670 case eeFFRIENDLY08:
2671 case eeFFRIENDLY09:
2672 case eeFFRIENDLY10:
2673 {
2674 enemy *e = new eFriendly(x,y,new_id,clk);
2675 guys.add(e);
2676 e->x = x;
2677 e->y = y;
2678 break;
2679 }
2680
2681
2682 default: break;
2683 }
2684
2685 // add segments of segmented enemies
2686 int32_t c=0;
2687
2688 switch(guysbuf[new_id&0xFFF].family)
2689 {
2690 case eeMOLD:
2691 {
2692 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2693 new_id &= 0xFFF;
2694
2695 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2696 {
2697 //christ this is messy -DD
2698 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2699
2700 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2701 {
2702 al_trace("Moldorm segment %d could not be created!\n",i+1);
2703
2704 for(int32_t j=0; j<i+1; j++)
2705 guys.del(guys.Count()-1);
2706
2707 return 0;
2708 }
2709
2710 if(i>0)
2711 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2712
2713
2714 }
2715
2716 break;
2717 }
2718
2719 case eeLANM:
2720 {
2721 new_id &= 0xFFF;
2722 int32_t shft = guysbuf[new_id].attributes[1];
2723 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2724 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2725
2726 if(!guys.add(e))
2727 {
2728 al_trace("Lanmola segment 1 could not be created!\n");
2729 guys.del(guys.Count()-1);
2730 return 0;
2731 }
2732 e->x = x;
2733 e->y = y;
2734
2735
2736
2737 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2738 {
2739 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2740 if(!guys.add(e2))
2741 {
2742 al_trace("Lanmola segment %d could not be created!\n",i+1);
2743
2744 for(int32_t j=0; j<i+1; j++)
2745 guys.del(guys.Count()-1);
2746
2747 return 0;
2748 }
2749 e2->x = x;
2750 e2->y = y;
2751
2752 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2753
2754 }
2755 }
2756 break;
2757
2758 case eeMANHAN:
2759 new_id &= 0xFFF;
2760
2761 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2762 {
2763 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2764 {
2765 al_trace("Manhandla head %d could not be created!\n",i+1);
2766
2767 for(int32_t j=0; j<i+1; j++)
2768 {
2769 guys.del(guys.Count()-1);
2770 }
2771
2772 return 0;
2773 }
2774
2775
2776 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2777 }
2778
2779 break;
2780
2781 case eeGLEEOK:
2782 {
2783 /*
2784 new_id &= 0xFFF;
2785 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2786 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2787 for(int32_t i=0; i<head_cnt; i++)
2788 {
2789 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2790 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2791 {
2792 al_trace("Gleeok head %d could not be created!\n",i+1);
2793
2794 for(int32_t j=0; j<i+1; j++)
2795 {
2796 guys.del(guys.Count()-1);
2797 }
2798
2799 break;
2800 }
2801
2802 c-=guysbuf[new_id].misc4;
2803 */
2804
2805 // }
2806 }
2807 break;
2808
2809
2810 case eePATRA:
2811 {
2812 new_id &= 0xFFF;
2813 int32_t outeyes = 0;
2814 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2815
2816 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2817 {
2818 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2819 {
2820 al_trace("Patra outer eye %d could not be created!\n",i+1);
2821
2822 for(int32_t j=0; j<i+1; j++)
2823 guys.del(guys.Count()-1);
2824
2825 return 0;
2826 }
2827 else
2828 outeyes++;
2829
2830
2831 }
2832
2833 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2834 {
2835 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2836 {
2837 al_trace("Patra inner eye %d could not be created!\n",i+1);
2838
2839 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2840 guys.del(guys.Count()-1);
2841
2842 return 0;
2843 }
2844
2845
2846 }
2847 delete ptra;
2848 break;
2849 }
2850 }
2851
2852
2853 // TODO(crash): check that the above .add succeeded.
2854 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2855 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2856 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2857 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2858 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2859 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2860 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2861 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2862 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2863 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2864 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2865 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2866
2867
2868 item_set = 0; //Do not make a drop.
2869
2870 switch(effect_type)
2871 {
2872 case -7:
2873 {
2874 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2875 Lwpns.add(w);
2876 break;
2877 }
2878 case -6:
2879 {
2880 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2881 Lwpns.add(w);
2882 break;
2883 }
2884 case -5:
2885 {
2886 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2887 Lwpns.add(w);
2888 break;
2889 }
2890 case -4:
2891 {
2892 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2893 Lwpns.add(w);
2894 break;
2895 }
2896 case -3: explode(1); break;
2897 case -2: explode(2); break;
2898 case -1: explode(0); break;
2899 case 0: break;
2900
2901 default:
2902 {
2903 //Dummy weapon function
2904 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2905 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2906 Lwpns.add(w);
2907 break;
2908 }
2909 }
2910
2911
2912 yofs = -32768;
2913 switch(guysbuf[new_id&0xFFF].family)
2914 {
2915 case eeGLEEOK:
2916 {
2917 Z_scripterrlog("Replacing a gleeok.\n");
2918 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2919 hp = -999;
2920 tempenemy->hp = -999;
2921 break;
2922
2923 }
2924 default:
2925 hp = -1000; break;
2926 }
2927 int mi = mapind(cur_map, screen_spawned);
2928 ++game->guys[mi];
2929 return 1;
2930
2931 }
2932 case edSPLIT:
2933 {
2934 for ( int32_t q = 0; q < dmisc4; q++ )
2935 {
2936 addenemy(screen_spawned,x,y,
2937 dmisc3+0x1000,-15);
2938
2939 }
2940 item_set = 0; //Do not make a drop.
2941 hp = -1000;
2942 return -1;
2943
2944 }
2945 case edSUMMON:
2946 {
2947 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
2948 for ( int32_t q = 0; q < summon_count; q++ )
2949 {
2950 int32_t x2=16*((zc_oldrand()%12)+2);
2951 int32_t y2=16*((zc_oldrand()%7)+2);
2952 addenemy(screen_spawned,
2953 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2954 x2,y2,
2955 dmisc3+0x1000,-15);
2956
2957 }
2958 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2959 return -1;
2960
2961 }
2962
2963 case edEXPLODESMALL:
2964 {
2965 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2966 Ewpns.add(ew);
2967 item_set = 0; //Should we make a drop?
2968 hp = -1000;
2969 return -1;
2970 }
2971
2972
2973 case edEXPLODEHARMLESS:
2974 {
2975 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2976 Ewpns.add(ew);
2977 ew->hyofs = -32768;
2978 item_set = 0; //Should we make a drop?
2979 hp = -1000;
2980 return -1;
2981 }
2982
2983
2984 case edEXPLODELARGE:
2985 {
2986 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2987 Ewpns.add(ew);
2988
2989 hp = -1000;
2990 return -1;
2991 }
2992
2993
2994 case edTRIGGERSECRETS:
2995 {
2996 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
2997 return -1;
2998 }
2999
3000 case edSTUNORCHINK:
3001
3/4
✓ Branch 0 taken 1119 times.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 1119 times.
✗ Branch 3 not taken.
3701 if (stunclk && get_qr(qr_NO_STUNLOCK))
3002 {
3003 sfx(WAV_CHINK,pan(int32_t(x)));
3004 return 1;
3005 }
3006
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1526 times.
2175 else if(*power <= 0)
3007 {
3008 649 sfx(WAV_CHINK,pan(int32_t(x)));
3009 649 return 1;
3010 }
3011 [[fallthrough]];
3012
3013 case edSTUNORIGNORE:
3014
3/4
✓ Branch 0 taken 1952 times.
✓ Branch 1 taken 1505 times.
✓ Branch 2 taken 1952 times.
✗ Branch 3 not taken.
5959 if (stunclk && get_qr(qr_NO_STUNLOCK))
3015 {
3016 sfx(WAV_CHINK,pan(int32_t(x)));
3017 return 1;
3018 }
3019
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 2502 times.
3457 else if(*power <= 0)
3020 955 return 0;
3021 [[fallthrough]];
3022
3023 case edSTUNONLY:
3024
7/10
✓ Branch 0 taken 4364 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4364 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4364 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3817 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4043 times.
✓ Branch 9 taken 321 times.
4364 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3025 {
3026 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3027 321 return 1;
3028 }
3029
3/4
✓ Branch 0 taken 3118 times.
✓ Branch 1 taken 925 times.
✓ Branch 2 taken 3118 times.
✗ Branch 3 not taken.
4043 if (stunclk && get_qr(qr_NO_STUNLOCK))
3030 {
3031 sfx(WAV_CHINK,pan(int32_t(x)));
3032 return 1;
3033 }
3034 else
3035 {
3036 4043 stunclk=160;
3037 4043 sfx(WAV_EHIT,pan(int32_t(x)));
3038
3039 4043 return 1;
3040 }
3041
3042 case edCHINKL1:
3043 if(*power >= 1*game->get_hero_dmgmult()) break;
3044 [[fallthrough]];
3045 case edCHINKL2:
3046
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3047 [[fallthrough]];
3048 case edCHINKL4:
3049
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3050 [[fallthrough]];
3051 case edCHINKL6:
3052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3053 [[fallthrough]];
3054 case edCHINKL8:
3055
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3056 [[fallthrough]];
3057 case edCHINKL10:
3058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3059 [[fallthrough]];
3060 case edCHINK:
3061 1056 sfx(WAV_CHINK,pan(int32_t(x)));
3062 1056 return 1;
3063
3064 case edIGNOREL1:
3065 if(*power > 0) break;
3066 [[fallthrough]];
3067
3068 case edIGNORE:
3069 17349 return 0;
3070
3071 case ed1HKO:
3072 492 *power = hp;
3073 492 return -2;
3074
3075 case ed2x:
3076 {
3077
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3078 //int32_t pow = *power;
3079 //*power = vbound((pow*2),0,214747);
3080 71 return -1;
3081 }
3082 case ed3x:
3083 {
3084 *power = zc_max(1,*power*3);
3085 //int32_t pow = *power;
3086 //*power = vbound((pow*3),0,214747);
3087 return -1;
3088 }
3089
3090 case ed4x:
3091 {
3092 *power = zc_max(1,*power*4);
3093 //int32_t pow = *power;
3094 //*power = vbound((pow*4),0,214747);
3095 return -1;
3096 }
3097
3098
3099 case edHEAL:
3100 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3101 //int32_t pow = *power;
3102 //*power = vbound((pow*-1),0,214747);
3103 //break;
3104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3105 158 return -1;
3106 }
3107 /*
3108 case edLEVELDAMAGE:
3109 {
3110 int32_t pow = *power;
3111 int32_t lvl = *level;
3112 *power = vbound((pow*lvl),0,214747);
3113 break;
3114 }
3115 case edLEVELREDUCTION:
3116 {
3117 int32_t pow = *power;
3118 int32_t lvl = *level;
3119 *power = vbound((pow/lvl),0,214747);
3120 break;
3121 }
3122 */
3123
3124 case edQUARTDAMAGE:
3125
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 3 times.
105 *power = zc_max(1,*power/2);
3126
3127 [[fallthrough]];
3128 case edHALFDAMAGE:
3129
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 156 times.
988 *power = zc_max(1,*power/2);
3130 988 break;
3131
3132 case edSWITCH:
3133 {
3134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(family)
3136 {
3137 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3138 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3139 return 0;
3140 }
3141 4 hooked_comborpos = rpos_t::None;
3142 4 hooked_layerbits = 0;
3143 4 switching_object = this;
3144 4 switch_hooked = true;
3145 4 Hero.doSwitchHook(game->get_switchhookstyle());
3146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3147 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
3148 4 return 1;
3149 }
3150
3151 case 0:
3152 {
3153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93415 times.
93415 if(edef == edefSwitchHook)
3154 return -1;
3155
6/6
✓ Branch 0 taken 19532 times.
✓ Branch 1 taken 73883 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 19474 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 26 times.
93415 if (stunclk && get_qr(qr_NO_STUNLOCK) && *power == 0)
3156 {
3157 26 sfx(WAV_CHINK,pan(int32_t(x)));
3158 26 return 1;
3159 }
3160
3161 }
3162 93389 }
3163
3164 94552 return -1;
3165 126299 }
3166
3167 126299 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3168 {
3169
1/2
✓ Branch 0 taken 126299 times.
✗ Branch 1 not taken.
126299 int wuid = w?w->getUID():0;
3170
1/2
✓ Branch 0 taken 126299 times.
✗ Branch 1 not taken.
126299 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3171
3172
1/2
✓ Branch 0 taken 126299 times.
✗ Branch 1 not taken.
126299 if(fakeweap)
3173 Lwpns.add(w);
3174 126299 std::vector<int32_t> &ev = FFCore.eventData;
3175 126299 ev.clear();
3176 126299 ev.push_back(*power*10000);
3177 126299 ev.push_back(edef*10000);
3178 126299 ev.push_back(unblockable*10000);
3179 126299 ev.push_back(wpnId*10000);
3180 126299 ev.push_back(0);
3181 126299 ev.push_back(getUID());
3182 126299 ev.push_back(wuid);
3183
3184 126299 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3185 126299 *power = ev[0]/10000;
3186 126299 edef = ev[1]/10000;
3187 126299 unblockable = byte(ev[2]/10000);
3188 126299 wpnId = ev[3] / 10000;
3189 126299 bool nullify = ev[4]!=0;
3190 126299 ev.clear();
3191 126299 int ret = 0;
3192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126299 times.
126299 if(!nullify)
3193 {
3194 126299 ret = defendNew(wpnId, power, edef, unblockable);
3195
2/2
✓ Branch 0 taken 32880 times.
✓ Branch 1 taken 93419 times.
126299 if(ret == -1)
3196 {
3197 93419 ev.push_back(*power*10000);
3198 93419 ev.push_back(edef*10000);
3199 93419 ev.push_back(unblockable*10000);
3200 93419 ev.push_back(wpnId*10000);
3201 93419 ev.push_back(0);
3202 93419 ev.push_back(getUID());
3203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93419 times.
93419 ev.push_back(w?w->getUID():0);
3204
3205 93419 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3206 93419 *power = ev[0]/10000;
3207 93419 nullify = ev[4]!=0;
3208 93419 ev.clear();
3209 93419 }
3210 126299 }
3211
1/2
✓ Branch 0 taken 126299 times.
✗ Branch 1 not taken.
126299 if(fakeweap)
3212 Lwpns.remove(w);
3213
3214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126299 times.
126299 return nullify ? 0 : ret;
3215 }
3216
3217 99490 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3218 {
3219
2/2
✓ Branch 0 taken 98913 times.
✓ Branch 1 taken 577 times.
99490 if(!realweap) realweap = w;
3220 99490 int32_t wid = getWeaponID(w);
3221
3222 99490 int32_t edef = resolveEnemyDefence(w);
3223
2/2
✓ Branch 0 taken 6267 times.
✓ Branch 1 taken 93223 times.
99490 if(QHeader.zelda_version > 0x250)
3224 6267 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3225
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92230 times.
✗ Branch 2 not taken.
93223 switch(wid)
3226 {
3227 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3228 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3229 993 return defend(wpnId, power, edefSCRIPT);
3230
3231 case wWhistle:
3232 return -1;
3233
3234 default:
3235 92230 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3236 }
3237 99490 }
3238
3239
3240 // Check defenses without actually acting on them.
3241 27402 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3242 {
3243
4/10
✓ Branch 0 taken 15409 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27402 switch(defense[edef])
3244 {
3245 case edSTUNONLY:
3246 474 return false;
3247 case edSTUNORCHINK:
3248 case edCHINK:
3249 15409 return unblockable&WPNUNB_BLOCK;
3250 case edSTUNORIGNORE:
3251 case edIGNORE:
3252 11050 return unblockable&WPNUNB_IGNR;
3253
3254 case edIGNOREL1:
3255 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3256 case edCHINKL1:
3257 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3258
3259 case edCHINKL2:
3260 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3261
3262 case edCHINKL4:
3263 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3264
3265 case edCHINKL6:
3266 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3267
3268 case edCHINKL8:
3269 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3270 }
3271
3272 469 return true;
3273 27402 }
3274
3275 // Do we do damage?
3276 // 0: takehit returns 0
3277 // 1: takehit returns 1
3278 // -1: do damage
3279 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3280 {
3281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3282 {
3283 switch(defense[edef])
3284 {
3285 case edIGNORE:
3286 return 0;
3287 case edIGNOREL1:
3288 case edSTUNORIGNORE:
3289 if(*power <= 0)
3290 return 0;
3291 }
3292
3293 sfx(WAV_CHINK,pan(int32_t(x)));
3294 return 1;
3295 }
3296
3297
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3298 {
3299 case edSTUNORCHINK:
3300 if(*power <= 0)
3301 {
3302 sfx(WAV_CHINK,pan(int32_t(x)));
3303 return 1;
3304 }
3305
3306 [[fallthrough]];
3307 case edSTUNORIGNORE:
3308 if(*power <= 0)
3309 return 0;
3310
3311 [[fallthrough]];
3312 case edSTUNONLY:
3313 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3314 return 1;
3315
3316 stunclk=160;
3317 sfx(WAV_EHIT,pan(int32_t(x)));
3318 return 1;
3319
3320 case edFREEZE:
3321 frozenclock=-1;
3322 //sfx(WAV_FREEZE,pan(int32_t(x)));
3323 return 1;
3324
3325 case edCHINKL1:
3326 if(*power >= 1*game->get_hero_dmgmult()) break;
3327 [[fallthrough]];
3328 case edCHINKL2:
3329 if(*power >= 2*game->get_hero_dmgmult()) break;
3330 [[fallthrough]];
3331 case edCHINKL4:
3332 if(*power >= 4*game->get_hero_dmgmult()) break;
3333 [[fallthrough]];
3334 case edCHINKL6:
3335 if(*power >= 6*game->get_hero_dmgmult()) break;
3336 [[fallthrough]];
3337 case edCHINKL8:
3338 if(*power >= 8*game->get_hero_dmgmult()) break;
3339 [[fallthrough]];
3340 case edCHINKL10:
3341 if(*power >= 10*game->get_hero_dmgmult()) break;
3342 [[fallthrough]];
3343 case edCHINK:
3344 sfx(WAV_CHINK,pan(int32_t(x)));
3345 return 1;
3346 case edTRIGGERSECRETS:
3347 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
3348 break;
3349
3350 case edIGNOREL1:
3351 if(*power > 0) break;
3352 [[fallthrough]];
3353 case edIGNORE:
3354 800 return 0;
3355
3356 case ed1HKO:
3357 *power = hp;
3358 return -2;
3359
3360 case ed2x:
3361 {
3362 *power = zc_max(1,*power*2);
3363 //int32_t pow = *power;
3364 //*power = vbound((pow*2),0,214747);
3365 return -1;
3366 }
3367 case ed3x:
3368 {
3369 *power = zc_max(1,*power*3);
3370 //int32_t pow = *power;
3371 //*power = vbound((pow*3),0,214747);
3372 return -1;
3373 }
3374
3375 case ed4x:
3376 {
3377 *power = zc_max(1,*power*4);
3378 //int32_t pow = *power;
3379 //*power = vbound((pow*4),0,214747);
3380 return -1;
3381 }
3382
3383
3384 case edHEAL:
3385 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3386 //int32_t pow = *power;
3387 //*power = vbound((pow*-1),0,214747);
3388 //break;
3389 *power = zc_min(0,*power*-1);
3390 return -1;
3391 }
3392 /*
3393 case edLEVELDAMAGE:
3394 {
3395 int32_t pow = *power;
3396 int32_t lvl = *level;
3397 *power = vbound((pow*lvl),0,214747);
3398 break;
3399 }
3400 case edLEVELREDUCTION:
3401 {
3402 int32_t pow = *power;
3403 int32_t lvl = *level;
3404 *power = vbound((pow/lvl),0,214747);
3405 break;
3406 }
3407 */
3408
3409
3410 case edQUARTDAMAGE:
3411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3412
3413 [[fallthrough]];
3414 case edHALFDAMAGE:
3415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3416 7 break;
3417 }
3418
3419 193 return -1;
3420 993 }
3421
3422 // Defend against a particular item class.
3423 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3424 {
3425 int32_t def=-1;
3426
3427 switch(wpnId)
3428 {
3429 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3430 case wBrang:
3431 def = defend(wpnId, power, edefBRANG);
3432 break;
3433
3434 case wHookshot:
3435 def = defend(wpnId, power, edefHOOKSHOT);
3436 break;
3437
3438 // Anyway...
3439 case wBomb:
3440 def = defend(wpnId, power, edefBOMB);
3441 break;
3442
3443 case wSBomb:
3444 def = defend(wpnId, power, edefSBOMB);
3445 break;
3446
3447 case wArrow:
3448 def = defend(wpnId, power, edefARROW);
3449 break;
3450
3451 case wFire:
3452 def = defend(wpnId, power, edefFIRE);
3453 break;
3454
3455 case wWand:
3456 def = defend(wpnId, power, edefWAND);
3457 break;
3458
3459 case wMagic:
3460 def = defend(wpnId, power, edefMAGIC);
3461 break;
3462
3463 case wHammer:
3464 def = defend(wpnId, power, edefHAMMER);
3465 break;
3466
3467 case wSword:
3468 def = defend(wpnId, power, edefSWORD);
3469 break;
3470
3471 case wBeam:
3472 def = defend(wpnId, power, edefBEAM);
3473 break;
3474
3475 case wRefBeam:
3476 def = defend(wpnId, power, edefREFBEAM);
3477 break;
3478
3479 case wRefMagic:
3480 def = defend(wpnId, power, edefREFMAGIC);
3481 break;
3482
3483 case wRefFireball:
3484 def = defend(wpnId, power, edefREFBALL);
3485 break;
3486
3487 case wRefRock:
3488 def = defend(wpnId, power, edefREFROCK);
3489 break;
3490
3491 case wStomp:
3492 def = defend(wpnId, power, edefSTOMP);
3493 break;
3494
3495 case wCByrna:
3496 def = defend(wpnId, power, edefBYRNA);
3497 break;
3498
3499 case wScript1:
3500 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3501 else def = defend(wpnId, power, edefSCRIPT);
3502 break;
3503
3504 case wScript2:
3505 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3506 else def = defend(wpnId, power, edefSCRIPT);
3507 break;
3508
3509 case wScript3:
3510 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3511 else def = defend(wpnId, power, edefSCRIPT);
3512 break;
3513
3514 case wScript4:
3515 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3516 else def = defend(wpnId, power, edefSCRIPT);
3517 break;
3518
3519 case wScript5:
3520 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3521 else def = defend(wpnId, power, edefSCRIPT);
3522 break;
3523
3524 case wScript6:
3525 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3526 else def = defend(wpnId, power, edefSCRIPT);
3527 break;
3528
3529 case wScript7:
3530 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3531 else def = defend(wpnId, power, edefSCRIPT);
3532 break;
3533
3534 case wScript8:
3535 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3536 else def = defend(wpnId, power, edefSCRIPT);
3537 break;
3538
3539 case wScript9:
3540 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3541 else def = defend(wpnId, power, edefSCRIPT);
3542 break;
3543
3544 case wScript10:
3545 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3546 else def = defend(wpnId, power, edefSCRIPT);
3547 break;
3548
3549 case wWhistle:
3550 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3551 else break;
3552 break;
3553
3554 case wRefArrow:
3555 def = defend(wpnId, power, edefREFARROW);
3556 break;
3557 case wRefFire:
3558 def = defend(wpnId, power, edefREFFIRE);
3559 break;
3560 case wRefFire2:
3561 def = defend(wpnId, power, edefREFFIRE2);
3562 break;
3563
3564 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3565 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3566 //of the ten if the quest version is lower than N.
3567 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3568 //such as bool UseSeparatedScriptDefences. hah.
3569 default:
3570 //if(wpnId>=wScript1 && wpnId<=wScript10)
3571 // {
3572 // def = defend(wpnId, power, edefSCRIPT);
3573 // }
3574 // }
3575
3576 break;
3577 }
3578
3579 return def;
3580 }
3581
3582 // take damage or ignore it
3583 // -1: damage (if any) dealt
3584 // 1: blocked
3585 // 0: weapon passes through unhindered
3586 265040 int32_t enemy::takehit(weapon *w, weapon* realweap)
3587 {
3588
2/4
✓ Branch 0 taken 265040 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 265040 times.
265040 if(fallclk||drownclk) return 0;
3589
2/2
✓ Branch 0 taken 69773 times.
✓ Branch 1 taken 195267 times.
265040 if(!realweap) realweap = w;
3590 265040 int32_t wpnId = w->id;
3591 265040 int32_t power = w->power;
3592 265040 int32_t wpnx = w->x;
3593 265040 int32_t wpny = w->y;
3594 265040 int32_t enemyHitWeapon = w->parentitem;
3595 int32_t wpnDir;
3596 265040 int32_t parent_item = w->parentitem;
3597
3598
2/2
✓ Branch 0 taken 264925 times.
✓ Branch 1 taken 115 times.
265040 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3599 {
3600 115 wpnId = w->useweapon;
3601 115 }
3602
3603 // If it's a boomerang that just bounced, use the opposite direction;
3604 // otherwise, it might bypass a shield. This probably won't handle
3605 // every case correctly, but it's better than having shields simply
3606 // not work against boomerangs.
3607
8/8
✓ Branch 0 taken 25081 times.
✓ Branch 1 taken 239959 times.
✓ Branch 2 taken 15580 times.
✓ Branch 3 taken 9501 times.
✓ Branch 4 taken 14362 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 3306 times.
✓ Branch 7 taken 11056 times.
265040 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3608 11056 wpnDir = oppositeDir[w->dir];
3609 else
3610 253984 wpnDir = w->dir;
3611
3612
5/8
✓ Branch 0 taken 265040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 265040 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265040 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8040 times.
✓ Branch 7 taken 272366 times.
265040 if(dying || clk<0 || hclk>0 || superman)
3613 8040 return 0;
3614
3615 //Prevent boomerang from writing to hitby[] for more than one frame.
3616 //This also prevents stunlock.
3617 //if ( stunclk > 0 ) return 0;
3618 //this needs a rule for boomerangs that cannot stunlock!
3619 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3620 //sigh.
3621
3622 272366 int32_t ret = -1;
3623
3624 // This obscure quest rule...
3625
5/6
✓ Branch 0 taken 92144 times.
✓ Branch 1 taken 180222 times.
✓ Branch 2 taken 88641 times.
✓ Branch 3 taken 3503 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 88641 times.
272366 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3626 {
3627 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3628 3503 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3629 3503 wpnDir=zc_oldrand()&3;
3630
3631
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3036 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 189 times.
3503 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3632 {
3633 189 wpnDir=down;
3634 189 }
3635
4/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 2751 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 285 times.
3314 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3636 {
3637 285 wpnDir=right;
3638 285 }
3639
4/4
✓ Branch 0 taken 2342 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 2064 times.
3029 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3640 {
3641 2064 wpnDir=up;
3642 2064 }
3643 else
3644 {
3645 965 wpnDir=left;
3646 }
3647 3503 }
3648
3649 272366 int32_t xdir = dir;
3650 272366 shieldCanBlock=false;
3651
3652
4/4
✓ Branch 0 taken 261086 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 258319 times.
273128 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3653
6/6
✓ Branch 0 taken 18380 times.
✓ Branch 1 taken 15613 times.
✓ Branch 2 taken 26253 times.
✓ Branch 3 taken 247679 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 247571 times.
261086 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3654
4/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 246552 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 245790 times.
247571 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3655 )
3656 // The hammer should already be dealt with by subclasses (Walker etc.)
3657 {
3658
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 680 times.
✓ Branch 4 taken 5804 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 153 times.
✓ Branch 9 taken 1488 times.
46522 switch(wpnId)
3659 {
3660 // Weapons which shields protect against
3661 case wSword:
3662 case wWand:
3663
2/2
✓ Branch 0 taken 5802 times.
✓ Branch 1 taken 2 times.
5806 if(Hero.getCharging()>0)
3664 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3665
3666 [[fallthrough]];
3667 case wHookshot:
3668 case wHSHandle:
3669 case wBrang:
3670 6184 shieldCanBlock=true;
3671 6522 break;
3672
3673 case wBeam:
3674 case wRefBeam:
3675 // Mirror shielded enemies!
3676 #if 0
3677 if(false /*flags&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3678 {
3679 if(wpnId>wEnemyWeapons)
3680 return 0;
3681
3682 sfx(WAV_CHINK,pan(int32_t(x)));
3683 return 1;
3684 }
3685
3686 #endif
3687
3688 [[fallthrough]];
3689 case wRefRock:
3690 case wRefFireball:
3691 case wMagic:
3692 #if 0
3693 if(false /*flags&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3694 {
3695 sfx(WAV_CHINK,pan(int32_t(x)));
3696 return 3;
3697 }
3698
3699 #endif
3700
3701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 368 times.
368 if(wpnId>wEnemyWeapons)
3702 return 0;
3703
3704 [[fallthrough]];
3705 case wArrow:
3706 382 case wRefArrow:
3707 default:
3708 1870 shieldCanBlock=true;
3709 1870 break;
3710
3711 // Bombs
3712 case wSBomb:
3713 case wBomb:
3714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3715 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3716 {
3717 sfx(WAV_CHINK,pan(int32_t(x)));
3718 return 0;
3719 }
3720 else break;
3721
3722 // Weapons which ignore shields
3723 case wWhistle:
3724 case wHammer:
3725 153 break;
3726
3727 // Weapons which shouldn't be removed by shields
3728 case wLitBomb:
3729 case wLitSBomb:
3730 case wWind:
3731 case wPhantom:
3732 case wSSparkle:
3733 case wBait:
3734 864 return 0;
3735
3736 case wFire:
3737 case wRefFire:
3738 case wRefFire2:
3739 ;
3740 680 }
3741 8887 }
3742
3743
8/8
✓ Branch 0 taken 103171 times.
✓ Branch 1 taken 97833 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27402 times.
✓ Branch 5 taken 25035 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9056 times.
265957 switch(wpnId)
3744 {
3745 case wWhistle: //No longer completely ignore whistle weapons! -Z
3746 {
3747
3748
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3749 {
3750 423 return 0; break;
3751 }
3752 else
3753 {
3754 w->power = power = itemsbuf[parent_item].misc5;
3755
3756 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3757
3758 if(def <= 0)
3759 {
3760 if ( def == -2 ) hp -= hp;
3761 else hp -= power;
3762 return def;
3763 }
3764 break;
3765 }
3766 break;
3767 }
3768
3769 case wPhantom:
3770 270 return 0;
3771
3772 case wLitBomb:
3773 case wLitSBomb:
3774 case wBait:
3775 case wWind:
3776 case wSSparkle:
3777 103171 return 0;
3778
3779 case wFSparkle:
3780
3781 // Only take sparkle damage if the sparkle's parent item is not
3782 // defended against.
3783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27402 times.
27402 if(enemyHitWeapon > -1)
3784 {
3785 27402 int32_t p = 0;
3786 27402 int32_t f = itemsbuf[enemyHitWeapon].family;
3787
3788
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27402 times.
27402 switch(f)
3789 {
3790 case itype_arrow:
3791 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3792
3793 break;
3794
3795 case itype_cbyrna:
3796 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3797
3798 break;
3799
3800 case itype_brang:
3801
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26933 times.
27402 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3802
3803 469 break;
3804
3805 default:
3806 return 0;
3807 }
3808 469 }
3809
3810 469 wpnId = wSword;
3811 469 power = game->get_hero_dmgmult()>>1;
3812 469 goto fsparkle;
3813 break;
3814
3815 case wBrang:
3816 {
3817 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3818 25035 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3819 //preventing stunlock might be best, here. -Z
3820
2/2
✓ Branch 0 taken 5471 times.
✓ Branch 1 taken 19564 times.
25035 if(def >= 0) return def;
3821
3822 // Not hurt by 0-damage weapons
3823
2/2
✓ Branch 0 taken 3184 times.
✓ Branch 1 taken 16380 times.
19564 if(!(flags & guy_bhit))
3824 {
3825 16380 stunclk=160;
3826
3827
3/4
✓ Branch 0 taken 16380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✓ Branch 3 taken 15069 times.
16380 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3828 {
3829
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3830 1311 goto hitclock;
3831 }
3832
3833 15069 break;
3834 }
3835
3836
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 2793 times.
3184 if(!power)
3837
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
3838 else
3839 391 hp-=power;
3840
3841 3184 goto hitclock;
3842 }
3843
3844 case wHookshot:
3845 {
3846 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3847 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3848
3849
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3850
3851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3852
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3853 {
3854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3855 1625 stunclk=160;
3856
3857
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3858 {
3859
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3860 549 goto hitclock;
3861 }
3862
3863 1076 break;
3864 }
3865
3866
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
3867 else
3868 45 hp-=power;
3869
3870 148 goto hitclock;
3871 }
3872 break;
3873
3874 case wHSHandle:
3875 {
3876
3/4
✓ Branch 0 taken 9056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8533 times.
9056 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3877 523 return 0;
3878
3879
3/4
✓ Branch 0 taken 6093 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8533 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3880
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3881
3882 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3883
6/8
✓ Branch 0 taken 2787 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2787 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2285 times.
10245 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
3884
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3889 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2177 times.
2787 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3885 2177 return 0;
3886
3887 12102 power = game->get_hero_dmgmult();
3888 12571 }
3889
3890 fsparkle:
3891
3892 [[fallthrough]];
3893 default:
3894 // Work out the defenses!
3895 {
3896 98912 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3897
3898
2/2
✓ Branch 0 taken 26566 times.
✓ Branch 1 taken 72346 times.
98912 if(def >= 0)
3899 26566 return def;
3900
2/2
✓ Branch 0 taken 71886 times.
✓ Branch 1 taken 460 times.
72346 else if(def == -2)
3901 {
3902 460 ret = 0;
3903 460 }
3904 }
3905
3906
2/2
✓ Branch 0 taken 72344 times.
✓ Branch 1 taken 2 times.
144692 if(!power)
3907 {
3908
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3909 2 hp-=1;
3910 else
3911 {
3912 // Don't make a long chain of 'stun' hits
3913 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3914 return 1;
3915
3916
3917 if(!switch_hooked)
3918 stunclk=160;
3919 break;
3920 }
3921 2 }
3922 72344 else hp-=power;
3923
3924 hitclock:
3925 77549 hclk=33;
3926
3927 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3928
2/2
✓ Branch 0 taken 34649 times.
✓ Branch 1 taken 42900 times.
77549 if((dir&2)==(w->dir&2))
3929 {
3930 42900 sclk=(w->dir<<8)+16;
3931 42900 }
3932 77549 }
3933
3934
5/6
✓ Branch 0 taken 74130 times.
✓ Branch 1 taken 19564 times.
✓ Branch 2 taken 21979 times.
✓ Branch 3 taken 71715 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21979 times.
93694 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3935 {
3936 21979 fading=fade_blue_poof;
3937 21979 }
3938
3939
6/6
✓ Branch 0 taken 88410 times.
✓ Branch 1 taken 5284 times.
✓ Branch 2 taken 46745 times.
✓ Branch 3 taken 41665 times.
✓ Branch 4 taken 2155 times.
✓ Branch 5 taken 44590 times.
93694 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3940 {
3941
2/2
✓ Branch 0 taken 7432 times.
✓ Branch 1 taken 7 times.
7439 if( hitsfx > 0 ) //user-set hit sound.
3942 {
3943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7432 times.
7432 if (!dying) //don't play the hit sound on death! -Z
3944 7432 sfx(hitsfx, pan(int32_t(x)));
3945 7432 }
3946 7 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
3947 7439 }
3948 else //2.50.2 or earlier
3949 {
3950 86255 sfx(WAV_EHIT, pan(int32_t(x)));
3951 86255 sfx(hitsfx, pan(int32_t(x)));
3952 }
3953
2/2
✓ Branch 0 taken 93665 times.
✓ Branch 1 taken 29 times.
93694 if(family==eeGUY)
3954 29 sfx(WAV_EDEAD, pan(int32_t(x)));
3955
3956 // Penetrating weapons
3957
4/4
✓ Branch 0 taken 91820 times.
✓ Branch 1 taken 1874 times.
✓ Branch 2 taken 84915 times.
✓ Branch 3 taken 8779 times.
93694 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3958 {
3959 8779 int32_t item=enemyHitWeapon;
3960
3961
2/2
✓ Branch 0 taken 1612 times.
✓ Branch 1 taken 7167 times.
8779 if(wpnId==wArrow)
3962 {
3963 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3964
5/6
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1612 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].family == itype_arrow))
3965 379 return 0;
3966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1233 times.
1233 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3967 //if(item<0)
3968 else
3969 1233 item=current_item_id(itype_arrow);
3970 1233 }
3971
3972 else
3973 {
3974
3975 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3976
3/6
✓ Branch 0 taken 7149 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7149 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7167 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].family == itype_sword))
3977 return 0;
3978
3979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7167 times.
7167 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3980 else
3981 //if(item<0)
3982 7167 item=current_item_id(itype_sword);
3983 }
3984 8400 }
3985
3986 93315 return ret;
3987 269126 }
3988
3989 61862957 bool enemy::dont_draw()
3990 {
3991
6/6
✓ Branch 0 taken 61398444 times.
✓ Branch 1 taken 464513 times.
✓ Branch 2 taken 61327537 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 175008 times.
✓ Branch 5 taken 61223436 times.
61862957 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
3992 639521 return true;
3993
3994
2/2
✓ Branch 0 taken 1371825 times.
✓ Branch 1 taken 59851611 times.
61223436 if(flags&guy_invisible)
3995 1371825 return true;
3996
3997
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 59851179 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
59851611 if(flags&guy_lens_only && !lensclk)
3998 return true;
3999
4000 59851611 return false;
4001 61862957 }
4002
4003 #define DRAW_NORMAL 2
4004 #define DRAW_CLOAKED 1
4005 #define DRAW_INVIS 0
4006 // base drawing function to be used by all derived classes instead of
4007 // sprite::draw()
4008 44943461 void enemy::draw(BITMAP *dest)
4009 {
4010 44943461 didScriptThisFrame = false; //Since there's no better place to put it
4011
6/6
✓ Branch 0 taken 44178329 times.
✓ Branch 1 taken 765132 times.
✓ Branch 2 taken 44095679 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 317531 times.
✓ Branch 5 taken 43860798 times.
44943461 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4012 1082663 return;
4013
2/2
✓ Branch 0 taken 2767665 times.
✓ Branch 1 taken 41093133 times.
43860798 if(flags&guy_invisible)
4014 2767665 return;
4015
4016 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4017 // be cloaked if they have "invisible displays as cloaked" checked.
4018
4019 41093133 byte canSee = DRAW_NORMAL;
4020 //Enemy specific stuff
4021
2/2
✓ Branch 0 taken 41091969 times.
✓ Branch 1 taken 1164 times.
41093133 if ( editorflags & ENEMY_FLAG1 )
4022 {
4023 1164 canSee = DRAW_INVIS;
4024
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4025
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4026 {
4027 if (game->item[dmisc13])
4028 {
4029 canSee = DRAW_NORMAL;
4030 }
4031 //else if ( lensclk && getlensid.flags SHOWINVIS )
4032 //{
4033 //
4034 //}
4035 //else
4036 //{
4037 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4038 // //otherwisem invisible
4039 //}
4040 }
4041 1164 }
4042 //Room specific
4043 41093133 mapscr* scr = get_scr(screen_spawned);
4044
2/2
✓ Branch 0 taken 38921934 times.
✓ Branch 1 taken 2171199 times.
41093133 if (scr->flags3&fINVISROOM)
4045 {
4046
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
4048 2171199 }
4049 //Lens check
4050
2/2
✓ Branch 0 taken 27537 times.
✓ Branch 1 taken 41065596 times.
41093133 if (lensclk)
4051 {
4052
2/2
✓ Branch 0 taken 27105 times.
✓ Branch 1 taken 432 times.
27537 if(flags&guy_lens_only)
4053 {
4054
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4055 432 }
4056 27537 }
4057 else
4058 {
4059
2/2
✓ Branch 0 taken 40992180 times.
✓ Branch 1 taken 73416 times.
41065596 if(flags&guy_lens_only)
4060 73416 canSee = DRAW_INVIS;
4061 }
4062
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 41018553 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
41093133 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4063
3/4
✓ Branch 0 taken 40792549 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 40792549 times.
✗ Branch 3 not taken.
41093133 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4064
4065
2/2
✓ Branch 0 taken 41018553 times.
✓ Branch 1 taken 74580 times.
41093133 if (canSee == DRAW_INVIS)
4066 74580 return;
4067
4068
4/4
✓ Branch 0 taken 41016178 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 41016171 times.
41018553 if(fallclk||drownclk)
4069 {
4070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 if (canSee == DRAW_CLOAKED)
4071 {
4072 sprite::drawcloaked(dest);
4073 }
4074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 else if (canSee == DRAW_NORMAL)
4075 {
4076 2382 sprite::draw(dest);
4077 2382 }
4078 2382 return;
4079 }
4080 41016171 int32_t cshold=cs;
4081
4082
2/2
✓ Branch 0 taken 904173 times.
✓ Branch 1 taken 40111998 times.
41016171 if(dying)
4083 {
4084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 904173 times.
904173 if(clk2>=19)
4085 {
4086 if(!(clk2&2))
4087 {
4088 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4089 if (canSee == DRAW_CLOAKED)
4090 {
4091 sprite::drawcloaked(dest);
4092 }
4093 else if (canSee == DRAW_NORMAL)
4094 {
4095 sprite::draw(dest);
4096 }
4097 }
4098 return;
4099 }
4100
4101 904173 flip = 0;
4102 904173 tile = wpnsbuf[spr_death].tile;
4103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 904173 times.
904173 if ( do_animation )
4104 {
4105 904173 int32_t offs = 0;
4106
2/2
✓ Branch 0 taken 853040 times.
✓ Branch 1 taken 51133 times.
904173 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4107 {
4108
2/2
✓ Branch 0 taken 49506 times.
✓ Branch 1 taken 1627 times.
51133 if(clk2 > 2)
4109 {
4110 1627 spr_death_anim_clk=0;
4111 1627 clk2=1;
4112
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1613 times.
1627 if(hp > -1000)
4113 1613 death_sfx();
4114 1627 }
4115
4/4
✓ Branch 0 taken 38434 times.
✓ Branch 1 taken 12699 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 38032 times.
51133 if(clk2==1 && spr_death_anim_clk>-1)
4116 {
4117 38032 ++clk2;
4118
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35650 times.
38032 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4119
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 38011 times.
38032 spr_death_anim_frm *= zc_max(1,txsz);
4120 38032 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4121
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 37956 times.
38032 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4122
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35650 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 38030 times.
✓ Branch 4 taken 36423 times.
✓ Branch 5 taken 1609 times.
38032 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4123 {
4124 1609 spr_death_anim_clk=-1;
4125 1609 clk2=1;
4126 1609 }
4127 38032 }
4128 51133 tile += spr_death_anim_frm;
4129 51133 }
4130
2/2
✓ Branch 0 taken 315607 times.
✓ Branch 1 taken 537433 times.
853040 else if(BSZ)
4131 {
4132
2/2
✓ Branch 0 taken 248172 times.
✓ Branch 1 taken 67435 times.
315607 offs = zc_min((15-clk2)/3,4);
4133 315607 }
4134
4/4
✓ Branch 0 taken 358367 times.
✓ Branch 1 taken 179066 times.
✓ Branch 2 taken 179055 times.
✓ Branch 3 taken 179312 times.
537433 else if(clk2>6 && clk2<=12)
4135 {
4136 179312 offs = 1;
4137 179312 }
4138
4139
2/2
✓ Branch 0 taken 455704 times.
✓ Branch 1 taken 448469 times.
904173 if(offs)
4140 {
4141
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 448019 times.
448469 offs *= zc_max(1,txsz);
4142 448469 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4143
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 448031 times.
448469 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4144 448469 }
4145 904173 tile += offs;
4146 904173 }
4147
4148
6/6
✓ Branch 0 taken 853040 times.
✓ Branch 1 taken 51133 times.
✓ Branch 2 taken 537433 times.
✓ Branch 3 taken 315607 times.
✓ Branch 4 taken 189182 times.
✓ Branch 5 taken 348251 times.
904173 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4149 555922 cs = wpnsbuf[spr_death].csets&15;
4150 else
4151 348251 cs = (((clk2+5)>>1)&3)+6;
4152 904173 }
4153
3/4
✓ Branch 0 taken 1197951 times.
✓ Branch 1 taken 38914047 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1197951 times.
40111998 else if(hclk>0 && getCanFlicker())
4154 {
4155 1197951 cs = getFlashingCSet();
4156 1197951 }
4157 //draw every other frame for flickering enemies
4158
2/2
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 40768140 times.
41016171 if (is_hitflickerframe(false))
4159 {
4160
5/6
✓ Branch 0 taken 90246 times.
✓ Branch 1 taken 157785 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 90245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 157786 times.
248031 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4161
2/4
✓ Branch 0 taken 248031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
248031 if (game->get_spriteflickercolor() || temp_flicker_color)
4162 {
4163 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4164 sprite_flicker_color = temp_flicker_color;
4165 sprite::draw(dest);
4166 }
4167 248031 }
4168 else
4169 {
4170
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 40542978 times.
40768140 if (canSee == DRAW_CLOAKED)
4171 {
4172 225162 sprite::drawcloaked(dest);
4173 225162 }
4174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40542978 times.
40542978 else if (canSee == DRAW_NORMAL)
4175 {
4176
1/2
✓ Branch 0 taken 40542978 times.
✗ Branch 1 not taken.
40542978 if ( frozenclock < 0 )
4177 {
4178 if ( frozentile > 0 ) tile = frozentile;
4179 loadpalset(csBOSS,frozencset);
4180 }
4181 40542978 sprite::draw(dest);
4182 40542978 }
4183 }
4184 41016171 cs=cshold;
4185 44943461 }
4186
4187 //old zc bosses
4188 40915949 void enemy::drawzcboss(BITMAP *dest)
4189 {
4190 40915949 didScriptThisFrame = false; //Since there's no better place to put it
4191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40915949 times.
40915949 if(dont_draw())
4192 return;
4193
4194 40915949 int32_t cshold=cs;
4195
4196
2/2
✓ Branch 0 taken 783966 times.
✓ Branch 1 taken 40131983 times.
40915949 if(dying)
4197 {
4198
2/2
✓ Branch 0 taken 3960 times.
✓ Branch 1 taken 780006 times.
783966 if(clk2>=19)
4199 {
4200
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 1980 times.
3960 if(!(clk2&2))
4201 1980 sprite::drawzcboss(dest);
4202
4203 3960 return;
4204 }
4205
4206 780006 flip = 0;
4207 780006 tile = wpnsbuf[spr_death].tile;
4208
4209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780006 times.
780006 if ( do_animation )
4210 {
4211
2/2
✓ Branch 0 taken 775490 times.
✓ Branch 1 taken 4516 times.
780006 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4212 {
4213
2/2
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 6 times.
4516 if(clk2 > 2)
4214 {
4215 6 spr_death_anim_clk=0;
4216 6 clk2=1;
4217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(hp > -1000)
4218 6 death_sfx();
4219 6 }
4220
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 76 times.
4516 if(clk2==1 && spr_death_anim_clk>-1)
4221 {
4222 76 ++clk2;
4223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm *= zc_max(1,txsz);
4225 76 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4227
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 2 times.
76 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4228 {
4229 2 spr_death_anim_clk=-1;
4230 2 clk2=1;
4231 2 }
4232 76 }
4233 4516 tile += spr_death_anim_frm;
4234 4516 }
4235
2/2
✓ Branch 0 taken 278586 times.
✓ Branch 1 taken 496904 times.
775490 else if(BSZ)
4236
2/2
✓ Branch 0 taken 219134 times.
✓ Branch 1 taken 59452 times.
278586 tile += zc_min((15-clk2)/3,4);
4237
4/4
✓ Branch 0 taken 331233 times.
✓ Branch 1 taken 165671 times.
✓ Branch 2 taken 165514 times.
✓ Branch 3 taken 165719 times.
496904 else if(clk2>6 && clk2<=12)
4238 165719 ++tile;
4239 780006 }
4240
4241
6/6
✓ Branch 0 taken 775490 times.
✓ Branch 1 taken 4516 times.
✓ Branch 2 taken 496904 times.
✓ Branch 3 taken 278586 times.
✓ Branch 4 taken 183872 times.
✓ Branch 5 taken 313032 times.
780006 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4242 466974 cs = wpnsbuf[spr_death].csets&15;
4243 else
4244 313032 cs = (((clk2+5)>>1)&3)+6;
4245 780006 }
4246
2/2
✓ Branch 0 taken 38923503 times.
✓ Branch 1 taken 1208480 times.
40131983 else if(hclk>0)
4247 {
4248 1208480 cs = getFlashingCSet();
4249 1208480 }
4250
4251 40911989 mapscr* scr = get_scr(screen_spawned);
4252
4253
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38866370 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40919532 if((scr->flags3&fINVISROOM) &&
4254
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4256 7543 lensclk) && family!=eeGANON)
4257 {
4258 7543 sprite::drawcloaked(dest);
4259 7543 }
4260 else
4261 {
4262
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40880973 times.
40904446 if (is_hitflickerframe(true))
4263 {
4264
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4265
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4266 {
4267 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4268 sprite_flicker_color = temp_flicker_color;
4269 sprite::drawzcboss(dest);
4270 }
4271 23473 }
4272 else
4273 40880973 sprite::drawzcboss(dest);
4274 }
4275
4276 40911989 cs=cshold;
4277 40915949 }
4278
4279
4280 // similar to the overblock function--can do up to a 32x32 sprite
4281 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4282 323235 void enemy::drawblock(BITMAP *dest,int32_t mask)
4283 {
4284 323235 int32_t thold=tile;
4285 323235 int32_t t1=tile;
4286 323235 int32_t t2=tile+20;
4287 323235 int32_t t3=tile+1;
4288 323235 int32_t t4=tile+21;
4289
4290
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 323235 times.
323235 switch(mask)
4291 {
4292 case 1:
4293 enemy::drawzcboss(dest);
4294 break;
4295
4296 case 3:
4297 if(flip&2)
4298 zc_swap(t1,t2);
4299
4300 tile=t1;
4301 enemy::drawzcboss(dest);
4302 tile=t2;
4303 yofs+=16;
4304 enemy::drawzcboss(dest);
4305 yofs-=16;
4306 break;
4307
4308 case 5:
4309 t2=tile+1;
4310
4311 if(flip&1)
4312 zc_swap(t1,t2);
4313
4314 tile=t1;
4315 enemy::drawzcboss(dest);
4316 tile=t2;
4317 xofs+=16;
4318 enemy::drawzcboss(dest);
4319 xofs-=16;
4320 break;
4321
4322 case 15:
4323
2/2
✓ Branch 0 taken 316479 times.
✓ Branch 1 taken 6756 times.
323235 if(flip&1)
4324 {
4325 6756 zc_swap(t1,t3);
4326 6756 zc_swap(t2,t4);
4327 6756 }
4328
4329
1/2
✓ Branch 0 taken 323235 times.
✗ Branch 1 not taken.
323235 if(flip&2)
4330 {
4331 zc_swap(t1,t2);
4332 zc_swap(t3,t4);
4333 }
4334
4335 323235 tile=t1;
4336 323235 enemy::drawzcboss(dest);
4337 323235 tile=t2;
4338 323235 yofs+=16;
4339 323235 enemy::drawzcboss(dest);
4340 323235 yofs-=16;
4341 323235 tile=t3;
4342 323235 xofs+=16;
4343 323235 enemy::drawzcboss(dest);
4344 323235 tile=t4;
4345 323235 yofs+=16;
4346 323235 enemy::drawzcboss(dest);
4347 323235 xofs-=16;
4348 323235 yofs-=16;
4349 323235 break;
4350 }
4351
4352 323235 tile=thold;
4353 323235 }
4354
4355 20383183 void enemy::drawshadow(BITMAP *dest, bool translucent)
4356 {
4357
4/4
✓ Branch 0 taken 18371837 times.
✓ Branch 1 taken 2011346 times.
✓ Branch 2 taken 526918 times.
✓ Branch 3 taken 17844919 times.
20383183 if(dont_draw() || isSideViewGravity())
4358 {
4359 2538264 return;
4360 }
4361
4362
2/2
✓ Branch 0 taken 327616 times.
✓ Branch 1 taken 17517303 times.
17844919 if(dying)
4363 {
4364 327616 return;
4365 }
4366
4367 17517303 mapscr* scr = get_scr(screen_spawned);
4368
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 15799054 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 17170293 times.
17517303 if(((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4369 17517303 (darkroom))
4370 {
4371 347010 return;
4372 }
4373 else
4374 {
4375
4/4
✓ Branch 0 taken 16592782 times.
✓ Branch 1 taken 577511 times.
✓ Branch 2 taken 16545220 times.
✓ Branch 3 taken 47562 times.
17170293 if(enemycanfall(id, false) && shadowtile == 0)
4376 47562 shadowtile = wpnsbuf[spr_shadow].tile;
4377
4378
5/6
✓ Branch 0 taken 16226411 times.
✓ Branch 1 taken 943882 times.
✓ Branch 2 taken 16226411 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15648900 times.
✓ Branch 5 taken 577511 times.
17170293 if(z>0 || fakez>0 || !enemycanfall(id, false))
4379 {
4380
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1521118 times.
1521393 if(!shadow_overpit(this))
4381 1521118 sprite::drawshadow(dest,translucent);
4382 1521393 }
4383 }
4384 20383183 }
4385
4386 129181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4387 {
4388 129181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4389
4390
1/2
✓ Branch 0 taken 129181 times.
✗ Branch 1 not taken.
129181 if(sub!=NULL)
4391 {
4392 129181 xofs-=mx;
4393 129181 yofs-=my;
4394 129181 enemy::draw(sub);
4395 129181 xofs+=mx;
4396 129181 yofs+=my;
4397 129181 destroy_bitmap(sub);
4398 129181 }
4399 else
4400 enemy::draw(dest);
4401 129181 }
4402
4403 9 void enemy::init_size_flags()
4404 {
4405
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4406
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4407
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4408
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4409
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4410
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4411
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4412
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4413
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
4414 {
4415 yofs = (int32_t)d->yofs;
4416 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4417 }
4418
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4419 9 }
4420
4421 // override hit detection to check for invicibility, stunned, etc
4422 112584277 bool enemy::hit()
4423 {
4424
4/4
✓ Branch 0 taken 111257153 times.
✓ Branch 1 taken 1327124 times.
✓ Branch 2 taken 109453211 times.
✓ Branch 3 taken 1803942 times.
112584277 if(dying || hclk>0) return false;
4425 109453211 return sprite::hit();
4426 112584277 }
4427 730351 bool enemy::hit(sprite *s)
4428 {
4429
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4430 713374 return sprite::hit(s);
4431 730351 }
4432
4433 44696645 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4434 {
4435
2/2
✓ Branch 0 taken 3963681 times.
✓ Branch 1 taken 40732964 times.
44696645 if(!hit()) return false;
4436 40732964 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4437 44696645 }
4438 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4439 {
4440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4441 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4442 78011 }
4443
4444 11173507 bool enemy::hit(weapon *w)
4445 {
4446
2/2
✓ Branch 0 taken 1188477 times.
✓ Branch 1 taken 9985030 times.
11173507 if(!hit()) return false;
4447
4448
2/2
✓ Branch 0 taken 6647382 times.
✓ Branch 1 taken 3337648 times.
9985030 if (replay_version_check(0, 14))
4449 {
4450
4/6
✓ Branch 0 taken 6422331 times.
✓ Branch 1 taken 225051 times.
✓ Branch 2 taken 6422331 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6422331 times.
✗ Branch 5 not taken.
6647382 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4451 225051 return false;
4452 6422331 return sprite::hit(w);
4453 }
4454 3337648 return w->hit(this);
4455 11173507 }
4456
4457 9462063 bool enemy::can_pitfall(bool checkspawning)
4458 {
4459
4/4
✓ Branch 0 taken 9442252 times.
✓ Branch 1 taken 19811 times.
✓ Branch 2 taken 9431597 times.
✓ Branch 3 taken 30466 times.
9462063 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4460
2/2
✓ Branch 0 taken 9413891 times.
✓ Branch 1 taken 17706 times.
9431597 switch(guysbuf[id&0xFFF].family)
4461 {
4462 case eeAQUA:
4463 case eeDIG:
4464 case eeDONGO:
4465 case eeFAIRY:
4466 case eeGANON:
4467 case eeGHOMA:
4468 case eeGLEEOK:
4469 case eeGUY:
4470 case eeLANM:
4471 case eeMANHAN:
4472 case eeMOLD:
4473 case eeNONE:
4474 case eePATRA:
4475 case eeZORA:
4476 17706 return false; //Disallowed types
4477 default:
4478 9413891 return true;
4479 }
4480 9462063 }
4481 //Handle death
4482 37982333 void enemy::try_death(bool force_kill)
4483 {
4484
8/8
✓ Branch 0 taken 37925764 times.
✓ Branch 1 taken 56569 times.
✓ Branch 2 taken 37925753 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 43648 times.
✓ Branch 5 taken 37882105 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 43647 times.
37982333 if(!dying && (force_kill || (hp<=0 && !immortal)))
4485 {
4486 43658 std::vector<int32_t> &ev = FFCore.eventData;
4487 43658 ev.clear();
4488 43658 ev.push_back(10000);
4489 43658 ev.push_back(getUID());
4490
4491 43658 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4492 43658 bool isSaved = !ev[0];
4493 43658 ev.clear();
4494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43658 times.
43658 if(isSaved) return;
4495
4496
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 43608 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 44 times.
43658 if (itemguy && get_screen_state(screen_spawned).item_state == ScreenItemState::CarriedByEnemy)
4497 {
4498
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 44 times.
95 for(int32_t i=0; i<items.Count(); i++)
4499 {
4500
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 44 times.
51 if(((item*)items.spr(i))->pickup&ipENEMY && screen_spawned == ((item*)items.spr(i))->screen_spawned)
4501 {
4502
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 3 times.
44 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4503 {
4504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4505 {
4506 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4507 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4508 }
4509 else
4510 {
4511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(extend >= 3)
4512 {
4513 items.spr(i)->x = x+(txsz-1)*8;
4514 items.spr(i)->y = y-2+(tysz-1)*8;
4515 }
4516 else
4517 {
4518 3 items.spr(i)->x = x;
4519 3 items.spr(i)->y = y - 2;
4520 }
4521 }
4522 3 items.spr(i)->z = z;
4523 3 items.spr(i)->fakez = fakez;
4524 3 }
4525 else
4526 {
4527 41 items.spr(i)->x = x;
4528 41 items.spr(i)->y = y - 2;
4529 }
4530 44 }
4531 51 }
4532 44 }
4533
4534 43658 dying=true;
4535
4536
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 43626 times.
43658 if(fading==fade_flash_die)
4537 32 clk2=19+18*4;
4538 else
4539 {
4540 43626 clk2 = BSZ ? 15 : 19;
4541
4542
2/2
✓ Branch 0 taken 21061 times.
✓ Branch 1 taken 22565 times.
43626 if(fading!=fade_blue_poof)
4543 22565 fading=0;
4544 }
4545
4546
2/2
✓ Branch 0 taken 43608 times.
✓ Branch 1 taken 50 times.
43658 if(itemguy)
4547 {
4548 50 screen_item_set_state(screen_spawned, ScreenItemState::None);
4549 50 item_set=0;
4550 50 }
4551
6/6
✓ Branch 0 taken 42604 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 33915 times.
✓ Branch 3 taken 8689 times.
✓ Branch 4 taken 1428 times.
✓ Branch 5 taken 32487 times.
43658 if (screen_spawned < 128 && count_enemy && !script_spawned)
4552 32487 game->guys[mapind(cur_map, screen_spawned)] -= 1;
4553 43658 }
4554 37982333 }
4555
4556 // --==**==--
4557
4558 // Movement routines that can be used by derived classes as needed
4559
4560 // --==**==--
4561
4562 556466 void enemy::fix_coords(bool bound)
4563 {
4564
1/2
✓ Branch 0 taken 556466 times.
✗ Branch 1 not taken.
556466 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4565
1/2
✓ Branch 0 taken 556466 times.
✗ Branch 1 not taken.
556466 if(moveflags & move_ignore_screenedge) bound = false;
4566
4567
2/2
✓ Branch 0 taken 81680 times.
✓ Branch 1 taken 474786 times.
556466 if(bound)
4568 {
4569 474786 int w = world_w;
4570 474786 int h = world_h;
4571
4572
1/2
✓ Branch 0 taken 474786 times.
✗ Branch 1 not taken.
474786 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4573 {
4574
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474784 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
474786 x=vbound(x, 0, (( guysbuf[id].SIZEflags&OVERRIDE_TILE_WIDTH && !isflier(id) ) ? (w-((txsz-1)*16)) : w-16));
4575
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474784 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
474786 y=vbound(y, 0,(( guysbuf[id].SIZEflags&OVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (h-((txsz-1)*16)) : h-16));
4576 474786 }
4577 else
4578 {
4579 x=vbound(x, 0, w-16);
4580 y=vbound(y, 0, h-16);
4581 }
4582 474786 }
4583
4584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556466 times.
556466 if(!OUTOFBOUNDS(id, x, y))
4585 {
4586 556466 do_fix(x, 16, true);
4587
2/2
✓ Branch 0 taken 1139 times.
✓ Branch 1 taken 555327 times.
556466 if(isSideViewGravity())
4588 1139 do_fix(y,8,true);
4589 555327 else do_fix(y,16,true);
4590 556466 }
4591 556466 }
4592 9175 bool enemy::cannotpenetrate()
4593 {
4594
4/4
✓ Branch 0 taken 8994 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 8956 times.
9175 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
4595 }
4596
4597 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4598 {
4599 bool ok;
4600 562 int32_t dx = 0, dy = 0;
4601 562 int32_t sv = 8;
4602
4603 //Why is this here??? Why is it needed???
4604 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4605
4606
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4607 {
4608 case 8:
4609 case up:
4610
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4611 return false;
4612
4613 69 dy = dy1-s;
4614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4616 69 break;
4617
4618 case 12:
4619 case down:
4620
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4621 return false;
4622
4623 51 dy = dy2+s;
4624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4625 51 break;
4626
4627 case 14:
4628 case left:
4629 47 dx = dx1-s;
4630 47 sv = ((isSideViewGravity())?7:8);
4631
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4632
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4633 47 break;
4634
4635 case 10:
4636 case right:
4637 85 dx = dx2+s;
4638 85 sv = ((isSideViewGravity())?7:8);
4639
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4640 85 break;
4641
4642 case 9:
4643 case r_up:
4644 94 dx = dx2+s;
4645 94 dy = dy1-s;
4646
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4648 94 break;
4649
4650 case 11:
4651 case r_down:
4652 78 dx = dx2+s;
4653 78 dx = dy2+s;
4654
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4656 78 break;
4657
4658 case 13:
4659 case l_down:
4660 57 dx = dx1-s;
4661 57 dy = dy2+s;
4662
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4664 57 break;
4665
4666 case 15:
4667 case l_up:
4668 81 dx = dx1-s;
4669 81 dy = dy1-s;
4670
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4672 81 break;
4673
4674 default:
4675 db=99;
4676 return true;
4677 }
4678
4679 562 return ok;
4680 562 }
4681
4682
4683
4684
4685 // returns true if next step is ok, false if there is something there
4686 7359802 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4687 {
4688 7359802 bool ok = false; //initialise the var, son't just declare it
4689 7359802 int32_t dx = 0, dy = 0;
4690 7359802 int32_t sv = 8;
4691 7359802 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4692 //Why is this here??? Why is it needed???
4693 7359802 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7359802 times.
7359802 int32_t usexoffs = (SIZEflags&OVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7359802 times.
7359802 int32_t useyoffs = (SIZEflags&OVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4696
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7359789 times.
7359802 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4697
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7359789 times.
7359802 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4698 7359802 bool offgrid = OFFGRID_ENEMY;
4699
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7352511 times.
7359802 if(!offgrid)
4700 {
4701 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4702
1/2
✓ Branch 0 taken 7352511 times.
✗ Branch 1 not taken.
7352511 if(usehei<16)usehei=16;
4703
1/2
✓ Branch 0 taken 7352511 times.
✗ Branch 1 not taken.
7352511 if(usewid<16)usewid=16;
4704 7352511 }
4705
9/9
✓ Branch 0 taken 1331286 times.
✓ Branch 1 taken 1107707 times.
✓ Branch 2 taken 1227672 times.
✓ Branch 3 taken 1218294 times.
✓ Branch 4 taken 540601 times.
✓ Branch 5 taken 642269 times.
✓ Branch 6 taken 603869 times.
✓ Branch 7 taken 568437 times.
✓ Branch 8 taken 119667 times.
7359802 switch(ndir) //need to check every 8 pixels between two points
4706 {
4707 case 8:
4708 case up:
4709 {
4710
4/4
✓ Branch 0 taken 150777 times.
✓ Branch 1 taken 1180509 times.
✓ Branch 2 taken 150117 times.
✓ Branch 3 taken 660 times.
1331286 if(enemycanfall(id) && isSideViewGravity())
4711 660 return false;
4712
4713 1330626 dy = dy1-s;
4714
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1330146 times.
1330626 special = (special==spw_clipbottomright)?spw_none:special;
4715 1330626 tries = usewid/(offgrid ? 8 : 16);
4716 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4717
2/2
✓ Branch 0 taken 1130416 times.
✓ Branch 1 taken 1331276 times.
2461692 for ( ; tries > 0; --tries )
4718 {
4719
2/2
✓ Branch 0 taken 197586 times.
✓ Branch 1 taken 1133690 times.
1331276 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4720 1331276 try_x += (offgrid ? 8 : 16);
4721
2/2
✓ Branch 0 taken 1131066 times.
✓ Branch 1 taken 200210 times.
1331276 if (!ok) break;
4722 1131066 }
4723
2/2
✓ Branch 0 taken 1130416 times.
✓ Branch 1 taken 200210 times.
1330626 if(!ok) break;
4724
1/2
✓ Branch 0 taken 1130416 times.
✗ Branch 1 not taken.
1130416 if((usewid%16)>0) //Uneven width
4725 {
4726 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4727 }
4728 1130416 break;
4729 }
4730 case 12:
4731 case down:
4732 {
4733
4/4
✓ Branch 0 taken 180645 times.
✓ Branch 1 taken 927062 times.
✓ Branch 2 taken 179919 times.
✓ Branch 3 taken 726 times.
1107707 if(enemycanfall(id) && isSideViewGravity())
4734 726 return false;
4735
4736 1106981 dy = dy2+s;
4737 1106981 tries = usewid/(offgrid ? 8 : 16);
4738 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4739
2/2
✓ Branch 0 taken 900632 times.
✓ Branch 1 taken 1107765 times.
2008397 for ( ; tries > 0; --tries )
4740 {
4741
3/4
✓ Branch 0 taken 205601 times.
✓ Branch 1 taken 902164 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 902164 times.
1107765 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4742 1107765 try_x += (offgrid ? 8 : 16);
4743
2/2
✓ Branch 0 taken 901416 times.
✓ Branch 1 taken 206349 times.
1107765 if (!ok) break;
4744 901416 }
4745
2/2
✓ Branch 0 taken 900632 times.
✓ Branch 1 taken 206349 times.
1106981 if(!ok) break;
4746
1/2
✓ Branch 0 taken 900632 times.
✗ Branch 1 not taken.
900632 if((usewid%16)>0) //Uneven width
4747 {
4748 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4749 }
4750 900632 break;
4751 }
4752 case 14:
4753 case left:
4754 {
4755 1227672 dx = dx1-s;
4756 1227672 sv = ((isSideViewGravity())?7:0);
4757
4/4
✓ Branch 0 taken 1227049 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 1225281 times.
1227672 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4758 1227672 tries = usehei/(offgrid ? 8 : 16);
4759 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4760
2/2
✓ Branch 0 taken 1028525 times.
✓ Branch 1 taken 1228589 times.
2257114 for ( ; tries > 0; --tries )
4761 {
4762
2/2
✓ Branch 0 taken 197962 times.
✓ Branch 1 taken 1030627 times.
1228589 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4763 1228589 try_y += (offgrid ? 8 : 16);
4764
2/2
✓ Branch 0 taken 1029442 times.
✓ Branch 1 taken 199147 times.
1228589 if (!ok) break;
4765 1029442 }
4766
2/2
✓ Branch 0 taken 1028525 times.
✓ Branch 1 taken 199147 times.
1227672 if(!ok) break;
4767
1/2
✓ Branch 0 taken 1028525 times.
✗ Branch 1 not taken.
1028525 if((usehei%16)>0) //Uneven height
4768 {
4769 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4770 }
4771 1028525 break;
4772 }
4773 case 10:
4774 case right:
4775 {
4776 1218294 dx = dx2+s;
4777 1218294 sv = ((isSideViewGravity())?7:0);
4778 1218294 tries = usehei/(offgrid ? 8 : 16);
4779 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4780
2/2
✓ Branch 0 taken 1029982 times.
✓ Branch 1 taken 1219188 times.
2249170 for ( ; tries > 0; --tries )
4781 {
4782
3/4
✓ Branch 0 taken 186957 times.
✓ Branch 1 taken 1032231 times.
✓ Branch 2 taken 1032231 times.
✗ Branch 3 not taken.
1219188 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4783 1219188 try_y += (offgrid ? 8 : 16);
4784
2/2
✓ Branch 0 taken 1030876 times.
✓ Branch 1 taken 188312 times.
1219188 if (!ok) break;
4785 1030876 }
4786
2/2
✓ Branch 0 taken 1029982 times.
✓ Branch 1 taken 188312 times.
1218294 if(!ok) break;
4787
1/2
✓ Branch 0 taken 1029982 times.
✗ Branch 1 not taken.
1029982 if((usehei%16)>0) //Uneven height
4788 {
4789 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4790 }
4791 1029982 break;
4792 }
4793 case 9:
4794 case r_up:
4795 {
4796 540601 dx = dx2+s;
4797 540601 dy = dy1-s;
4798 540601 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4799 540601 sv = ((isSideViewGravity())?7:0);
4800
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 540601 times.
1064142 for ( ; tries_x > 0; --tries_x )
4801 {
4802 540601 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4803 540601 try_y = 0;
4804
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 540601 times.
1064142 for ( ; tries_y > 0; --tries_y )
4805 {
4806
4/4
✓ Branch 0 taken 532330 times.
✓ Branch 1 taken 8271 times.
✓ Branch 2 taken 526882 times.
✓ Branch 3 taken 5448 times.
1067483 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4807
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 524490 times.
526882 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4808 540601 try_y += (offgrid ? 8 : 16);
4809
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if (!ok) break;
4810 523541 }
4811
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if (!ok) break;
4812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 523541 times.
523541 if((usehei%16)>0) //Uneven height
4813 {
4814 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4815 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4816 }
4817 523541 try_x += (offgrid ? 8 : 16);
4818 523541 }
4819
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if(!ok) break;
4820
1/2
✓ Branch 0 taken 523541 times.
✗ Branch 1 not taken.
523541 if((usewid%16)>0) //Uneven width
4821 {
4822 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4823 try_y = 0;
4824 for ( ; tries_y > 0; --tries_y )
4825 {
4826 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4827 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4828 try_y += (offgrid ? 8 : 16);
4829 if (!ok) break;
4830 }
4831 if (!ok) break;
4832 if((usehei%16)>0) //Uneven height
4833 {
4834 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4835 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4836 }
4837 }
4838 523541 break;
4839 }
4840 case 11:
4841 case r_down:
4842 {
4843 642269 dx = dx2+s;
4844 642269 dx = dy2+s;
4845 642269 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4846 //sv = ((isSideViewGravity())?7:0);
4847
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 642269 times.
1269140 for ( ; tries_x > 0; --tries_x )
4848 {
4849 642269 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4850 642269 try_y = 0;
4851
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 642269 times.
1269140 for ( ; tries_y > 0; --tries_y )
4852 {
4853
4/4
✓ Branch 0 taken 640758 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 627938 times.
✓ Branch 3 taken 12820 times.
1270207 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4854
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 627832 times.
627938 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4855 642269 try_y += (offgrid ? 8 : 16);
4856
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if (!ok) break;
4857 626871 }
4858
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if (!ok) break;
4859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626871 times.
626871 if((usehei%16)>0) //Uneven height
4860 {
4861 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4862 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4863 }
4864 626871 try_x += (offgrid ? 8 : 16);
4865 626871 }
4866
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if(!ok) break;
4867
1/2
✓ Branch 0 taken 626871 times.
✗ Branch 1 not taken.
626871 if((usewid%16)>0) //Uneven width
4868 {
4869 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4870 try_y = 0;
4871 for ( ; tries_y > 0; --tries_y )
4872 {
4873 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4874 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4875 try_y += (offgrid ? 8 : 16);
4876 if (!ok) break;
4877 }
4878 if (!ok) break;
4879 if((usehei%16)>0) //Uneven height
4880 {
4881 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4882 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4883 }
4884 }
4885 626871 break;
4886 }
4887 case 13:
4888 case l_down:
4889 {
4890 603869 dx = dx1-s;
4891 603869 dy = dy2+s;
4892 603869 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4893 //sv = ((isSideViewGravity())?7:0);
4894
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 603869 times.
1190662 for ( ; tries_x > 0; --tries_x )
4895 {
4896 603869 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4897 603869 try_y = 0;
4898
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 603869 times.
1190662 for ( ; tries_y > 0; --tries_y )
4899 {
4900
4/4
✓ Branch 0 taken 591935 times.
✓ Branch 1 taken 11934 times.
✓ Branch 2 taken 587661 times.
✓ Branch 3 taken 4274 times.
1191530 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4901
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 587093 times.
587661 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4902 603869 try_y += (offgrid ? 8 : 16);
4903
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if (!ok) break;
4904 586793 }
4905
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if (!ok) break;
4906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 586793 times.
586793 if((usehei%16)>0) //Uneven height
4907 {
4908 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4909 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4910 }
4911 586793 try_x += (offgrid ? 8 : 16);
4912 586793 }
4913
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if(!ok) break;
4914
1/2
✓ Branch 0 taken 586793 times.
✗ Branch 1 not taken.
586793 if((usewid%16)>0) //Uneven width
4915 {
4916 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4917 try_y = 0;
4918 for ( ; tries_y > 0; --tries_y )
4919 {
4920 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4921 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4922 try_y += (offgrid ? 8 : 16);
4923 if (!ok) break;
4924 }
4925 if (!ok) break;
4926 if((usehei%16)>0) //Uneven height
4927 {
4928 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4929 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4930 }
4931 }
4932 586793 break;
4933 }
4934 case 15:
4935 case l_up:
4936 {
4937 568437 dx = dx1-s;
4938 568437 dy = dy1-s;
4939 568437 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4940 568437 sv = ((isSideViewGravity())?7:0);
4941
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 568437 times.
1120931 for ( ; tries_x > 0; --tries_x )
4942 {
4943 568437 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4944 568437 try_y = 0;
4945
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 568437 times.
1120931 for ( ; tries_y > 0; --tries_y )
4946 {
4947
4/4
✓ Branch 0 taken 559771 times.
✓ Branch 1 taken 8666 times.
✓ Branch 2 taken 555802 times.
✓ Branch 3 taken 3969 times.
1124239 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4948
2/2
✓ Branch 0 taken 2439 times.
✓ Branch 1 taken 553363 times.
555802 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4949 568437 try_y += (offgrid ? 8 : 16);
4950
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if (!ok) break;
4951 552494 }
4952
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if (!ok) break;
4953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 552494 times.
552494 if((usehei%16)>0) //Uneven height
4954 {
4955 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4956 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4957 }
4958 552494 try_x += (offgrid ? 8 : 16);
4959 552494 }
4960
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if(!ok) break;
4961
1/2
✓ Branch 0 taken 552494 times.
✗ Branch 1 not taken.
552494 if((usewid%16)>0) //Uneven width
4962 {
4963 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4964 try_y = 0;
4965 for ( ; tries_y > 0; --tries_y )
4966 {
4967 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4968 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4969 try_y += (offgrid ? 8 : 16);
4970 if (!ok) break;
4971 }
4972 if (!ok) break;
4973 if((usehei%16)>0) //Uneven height
4974 {
4975 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4976 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4977 }
4978 }
4979 552494 break;
4980 }
4981 default:
4982 119667 db=99;
4983 119667 return true;
4984 }
4985 //Z_eventlog("\n");
4986 7238749 return ok;
4987 7359802 }
4988
4989
4990 4652346 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4991 {
4992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652346 times.
4652346 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652346 times.
4652346 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4994
1/2
✓ Branch 0 taken 4652346 times.
✗ Branch 1 not taken.
4652346 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4995
1/2
✓ Branch 0 taken 4652346 times.
✗ Branch 1 not taken.
4652346 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4996 4652346 --usewid;
4997 4652346 --usehei;
4998 4652346 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
4999 }
5000
5001 1244678 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
5002 {
5003 1244678 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5004
5005
4/4
✓ Branch 0 taken 6819 times.
✓ Branch 1 taken 1237859 times.
✓ Branch 2 taken 5021 times.
✓ Branch 3 taken 1798 times.
1244678 if(special==spw_clipright&&ndir==right)
5006 {
5007 1798 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5008 1798 }
5009
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1244673 times.
1244678 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5010
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1244673 times.
1244678 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5011
1/2
✓ Branch 0 taken 1244678 times.
✗ Branch 1 not taken.
1244678 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5012
1/2
✓ Branch 0 taken 1244678 times.
✗ Branch 1 not taken.
1244678 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5013 1244678 --usewid;
5014 1244678 --usehei;
5015
2/2
✓ Branch 0 taken 717736 times.
✓ Branch 1 taken 526942 times.
1244678 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5016 }
5017
5018 136347 bool enemy::canmove(int32_t ndir, bool kb)
5019 {
5020 136347 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5021 }
5022
5023 // 8-directional
5024 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5025 {
5026 562 int32_t ndir=0;
5027
5028 // can move straight, check if it wants to turn
5029
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5030 {
5031
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5032 {
5033 int32_t w = Lwpns.idFirst(wBait);
5034
5035 if(w>=0)
5036 {
5037 int32_t bx = Lwpns.spr(w)->x;
5038 int32_t by = Lwpns.spr(w)->y;
5039
5040 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5041
5042 if(abs(int32_t(y)-by)>14)
5043 {
5044 if(ndir>0) // Already left or right
5045 {
5046 // Making the diagonal directions
5047 ndir += (by<y) ? 2 : 4;
5048 }
5049 else
5050 {
5051 ndir = (by<y) ? up : down;
5052 }
5053 }
5054
5055 if(canmove(ndir,special,false))
5056 {
5057 dir=ndir;
5058 return;
5059 }
5060 }
5061 }
5062
5063 // Homing added.
5064
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5065 {
5066 ndir = lined_up(8,true);
5067
5068 if(ndir>=0 && canmove(ndir,special,false))
5069 {
5070 dir=ndir;
5071 }
5072
5073 return;
5074 }
5075
5076 549 int32_t r=zc_oldrand();
5077
5078
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5079 {
5080 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5081 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5082
5083
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5084 525 dir=ndir;
5085
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5086 19 dir=ndir2;
5087
5088
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5089 // due to numerous lost fractional components. -L
5090 {
5091 x.doFloor();
5092 y.doFloor();
5093 }
5094 549 }
5095
5096 549 return;
5097 }
5098
5099 // can't move straight, must turn
5100 13 int32_t i=0;
5101
5102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5103 {
5104 20 ndir=(zc_oldrand()&7)+8;
5105
5106
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5107 13 break;
5108 7 }
5109
5110
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5111 {
5112 for(ndir=8; ndir<16; ndir++)
5113 {
5114 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5115 goto ok;
5116 }
5117
5118 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5119 }
5120
5121 ok:
5122 13 dir=ndir;
5123 13 x.doFloor();
5124 13 y.doFloor();
5125 562 }
5126
5127 580728 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5128 {
5129 580728 int32_t ndir=0;
5130
5131 // can move straight, check if it wants to turn
5132
2/2
✓ Branch 0 taken 548065 times.
✓ Branch 1 taken 32663 times.
580728 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5133 {
5134
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 547858 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
548065 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5135 {
5136 101 int32_t i = Lwpns.idFirst(wBait);
5137
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5138 {
5139 weapon *w = (weapon*)Lwpns.spr(i);
5140 if (get_qr(qr_FIND_CLOSEST_BAIT))
5141 {
5142 int32_t currentrange;
5143 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5144 else currentrange = -1;
5145 int curid = i;
5146 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5147 for(; i<Lwpns.Count(); ++i)
5148 {
5149 weapon *lw = (weapon*)Lwpns.spr(i);
5150 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5151 {
5152 currentrange = distance(x, y, lw->x, lw->y);
5153 curid = i;
5154 }
5155 }
5156 i = curid;
5157 if (currentrange == -1) i = -1;
5158 }
5159 else
5160 {
5161 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5162 }
5163 if(i>=0)
5164 {
5165 int32_t bx = Lwpns.spr(i)->x;
5166 int32_t by = Lwpns.spr(i)->y;
5167
5168 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5169
5170 if(abs(int32_t(y)-by)>14)
5171 {
5172 if(ndir>0) // Already left or right
5173 {
5174 // Making the diagonal directions
5175 ndir += (by<y) ? 2 : 4;
5176 }
5177 else
5178 {
5179 ndir = (by<y) ? up : down;
5180 }
5181 }
5182 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5183 if(canmove(ndir,special,false))
5184 {
5185 dir=ndir;
5186 return;
5187 }
5188 }
5189 }
5190 101 }
5191
5192 // Homing added.
5193
4/4
✓ Branch 0 taken 29626 times.
✓ Branch 1 taken 518439 times.
✓ Branch 2 taken 15410 times.
✓ Branch 3 taken 14216 times.
548065 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5194 {
5195 14216 ndir = lined_up(8,true);
5196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14216 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5197
4/4
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 4771 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5852 times.
14216 if(ndir>=0 && canmove(ndir,special,false))
5198 {
5199 5852 dir=ndir;
5200 5852 }
5201
5202 14216 return;
5203 }
5204
5205 533849 int32_t r=zc_oldrand();
5206
5207
4/4
✓ Branch 0 taken 340048 times.
✓ Branch 1 taken 193801 times.
✓ Branch 2 taken 179767 times.
✓ Branch 3 taken 160281 times.
533849 if(newrate>0 && !(r%newrate))
5208 {
5209 160281 ndir = ((dir+((r&64)?-1:1))&7)+8;
5210 160281 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5211
5212
2/2
✓ Branch 0 taken 154477 times.
✓ Branch 1 taken 5804 times.
160281 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5213 154477 dir=ndir;
5214
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 4947 times.
5804 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5215 4947 dir=ndir2;
5216
5217
4/4
✓ Branch 0 taken 154477 times.
✓ Branch 1 taken 5804 times.
✓ Branch 2 taken 147151 times.
✓ Branch 3 taken 7326 times.
160281 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5218 // due to numerous lost fractional components. -L
5219 {
5220 7326 x.doFloor();
5221 7326 y.doFloor();
5222 7326 }
5223 160281 }
5224
5225 533849 return;
5226 }
5227
5228 // can't move straight, must turn
5229 32663 int32_t i=0;
5230
5231 // TODO: speed this up!
5232
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 61154 times.
61224 for(; i<32; i++) // Try random dir
5233 {
5234 61154 ndir=(zc_oldrand()&7)+8;
5235
5236
2/2
✓ Branch 0 taken 28561 times.
✓ Branch 1 taken 32593 times.
61154 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5237 32593 break;
5238 28561 }
5239
5240
2/2
✓ Branch 0 taken 32593 times.
✓ Branch 1 taken 70 times.
32716 if(i==32)
5241 {
5242
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 53 times.
514 for(ndir=8; ndir<16; ndir++)
5243 {
5244
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 17 times.
461 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5245 17 goto ok;
5246 444 }
5247
5248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5249 53 }
5250
5251 ok:
5252 32663 dir=ndir;
5253 32663 x.doFloor();
5254 32663 y.doFloor();
5255 580728 }
5256
5257 574253 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5258 {
5259 574253 newdir_8(newrate,newhoming,special,0,-8,15,15);
5260 574253 }
5261
5262 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5263 {
5264 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5265 562 }
5266
5267 // makes the enemy slide backwards when hit
5268 // sclk: first byte is clk, second byte is dir
5269 // makes the enemy slide backwards when hit
5270 // sclk: first byte is clk, second byte is dir
5271 15643334 int32_t enemy::slide()
5272 {
5273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15643334 times.
15643334 if(script_knockback_clk!=0) //scripted knockback
5274 {
5275 sclk = 0;
5276 return 1; //scripted knockback ran
5277 }
5278
5/6
✓ Branch 0 taken 102111 times.
✓ Branch 1 taken 15541223 times.
✓ Branch 2 taken 7855 times.
✓ Branch 3 taken 94256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7855 times.
15643334 if(sclk==0 || (hp<=0 && !immortal))
5279 15549078 return 0;
5280
5281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94256 times.
94256 if(knockbackflags & FLAG_NOSLIDE)
5282 {
5283 sclk = 0;
5284 if(!OFFGRID_ENEMY)
5285 {
5286 //Fix to grid
5287 do_fix(x, 16, true);
5288 do_fix(y, 16, true);
5289 }
5290 return 0;
5291 }
5292
8/10
✓ Branch 0 taken 9554 times.
✓ Branch 1 taken 84702 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 9256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 298 times.
✓ Branch 6 taken 7103 times.
✓ Branch 7 taken 2153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 298 times.
94256 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5293 {
5294 2153 sclk=0;
5295 2153 return 0;
5296 }
5297
5298 92103 --sclk;
5299
5300
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10539 times.
✓ Branch 2 taken 12291 times.
✓ Branch 3 taken 31734 times.
✓ Branch 4 taken 35754 times.
92103 switch(sclk>>8)
5301 {
5302 case up:
5303 {
5304
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9449 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 10532 times.
10539 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5305 {
5306 7 sclk=0;
5307 7 return 0;
5308 }
5309
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9442 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
10532 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5310
5311 10357 break;
5312 }
5313 case down:
5314 {
5315
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12289 times.
12291 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5316 {
5317 2 sclk=0;
5318 2 return 0;
5319 }
5320
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 11220 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
12289 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5321
5322 12143 break;
5323 }
5324 case left:
5325 {
5326
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29380 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 31721 times.
31734 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5327 {
5328 13 sclk=0;
5329 13 return 0;
5330 }
5331
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29367 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
31721 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5332
5333 31483 break;
5334 }
5335 case right:
5336 {
5337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35754 times.
35754 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5338 {
5339 sclk=0;
5340 return 0;
5341 }
5342
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 32466 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
35754 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5343 35484 break;
5344 }
5345 }
5346
5347 91252 int32_t move = knockbackSpeed;
5348
2/2
✓ Branch 0 taken 86369 times.
✓ Branch 1 taken 91252 times.
177621 while(move>0)
5349 {
5350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91252 times.
91252 int32_t thismove = zc_min(8, move);
5351 91252 move -= thismove;
5352 91252 hitdir = (sclk>>8);
5353
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10357 times.
✓ Branch 2 taken 12143 times.
✓ Branch 3 taken 31483 times.
✓ Branch 4 taken 35484 times.
91252 switch(sclk>>8)
5354 {
5355 case up:
5356 10357 y-=thismove;
5357 10357 break;
5358
5359 case down:
5360 12143 y+=thismove;
5361 12143 break;
5362
5363 case left:
5364 31483 x-=thismove;
5365 31483 break;
5366
5367 case right:
5368 35484 x+=thismove;
5369 35484 break;
5370 }
5371
2/2
✓ Branch 0 taken 86369 times.
✓ Branch 1 taken 4883 times.
91252 if(!canmove(sclk>>8,(zfix)0,0,true))
5372 {
5373
3/3
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 2906 times.
✓ Branch 2 taken 4 times.
4883 switch(sclk>>8)
5374 {
5375 case up:
5376 case down:
5377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973 times.
1973 if(y < 0)
5378 y = 0;
5379
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 1648 times.
1973 else if((int32_t(y)&15) > 7)
5380 325 y = TRUNCATE_TILE(int32_t(y)) + 16;
5381 else
5382 1648 y = TRUNCATE_TILE(int32_t(y));
5383
5384 1973 break;
5385
5386 case left:
5387 case right:
5388
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2902 times.
2906 if(x < 0)
5389 4 x = 0;
5390
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 2069 times.
2902 else if((int32_t(x)&15) > 7)
5391 833 x = TRUNCATE_TILE(int32_t(x)) + 16;
5392 else
5393 2069 x = TRUNCATE_TILE(int32_t(x));
5394
5395 2906 break;
5396 }
5397
5398 4883 sclk=0;
5399 4883 clk3=0;
5400 4883 break;
5401 }
5402 }
5403
5404
2/2
✓ Branch 0 taken 83889 times.
✓ Branch 1 taken 7363 times.
91252 if((sclk&255)==0)
5405 {
5406 //hitdir = -1;
5407 7363 sclk=0;
5408 7363 }
5409 91252 return 2;
5410 15643334 }
5411
5412 bool enemy::can_slide()
5413 {
5414 if(sclk==0 || (hp<=0 && !immortal))
5415 return false;
5416
5417 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5418 {
5419 return false;
5420 }
5421
5422 return true;
5423 }
5424
5425 bool enemy::fslide()
5426 {
5427 if(sclk==0 || (hp<=0 && !immortal))
5428 return false;
5429
5430 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5431 {
5432 sclk=0;
5433 return false;
5434 }
5435
5436 --sclk;
5437
5438 switch(sclk>>8)
5439 {
5440 case up:
5441 if(y<=16)
5442 {
5443 sclk=0;
5444 return false;
5445 }
5446
5447 break;
5448
5449 case down:
5450 if(y>=world_h-16)
5451 {
5452 sclk=0;
5453 return false;
5454 }
5455
5456 break;
5457
5458 case left:
5459 if(x<=16)
5460 {
5461 sclk=0;
5462 return false;
5463 }
5464
5465 break;
5466
5467 case right:
5468 if(x>=world_w-16)
5469 {
5470 sclk=0;
5471 return false;
5472 }
5473
5474 break;
5475 }
5476 hitdir = (sclk>>8);
5477 switch(sclk>>8)
5478 {
5479 case up:
5480 y-=4;
5481 break;
5482
5483 case down:
5484 y+=4;
5485 break;
5486
5487 case left:
5488 x-=4;
5489 break;
5490
5491 case right:
5492 x+=4;
5493 break;
5494 }
5495
5496 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5497 {
5498 switch(sclk>>8)
5499 {
5500 case up:
5501 case down:
5502 if((int32_t(y)&15) > 7)
5503 y = TRUNCATE_TILE(int32_t(y)) + 16;
5504 else
5505 y = TRUNCATE_TILE(int32_t(y));
5506
5507 break;
5508
5509 case left:
5510 case right:
5511 if((int32_t(x)&15) > 7)
5512 x = TRUNCATE_TILE(int32_t(x)) + 16;
5513 else
5514 x = TRUNCATE_TILE(int32_t(x));
5515
5516 break;
5517 }
5518
5519 sclk=0;
5520 clk3=0;
5521 }
5522
5523 if((sclk&255)==0)
5524 sclk=0;
5525
5526 return true;
5527 }
5528
5529 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5530 {
5531 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5532 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5533 bool ret = sprite::knockback(time, dir, speed);
5534 if(ret) sclk = 0; //kill engine knockback if interrupted
5535 //! Perhaps also set hitdir here, if needed for timing? -Z
5536 return ret;
5537 }
5538
5539 37982322 bool enemy::runKnockback()
5540 {
5541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37982322 times.
37982322 if((script_knockback_clk&0xFF)==0)
5542 {
5543 37982322 script_knockback_clk = 0;
5544 37982322 return false;
5545 }
5546 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5547 {
5548 return false;
5549 }
5550 int32_t move = script_knockback_speed;
5551 int32_t kb_dir = script_knockback_clk>>8;
5552 --script_knockback_clk;
5553
5554 while(move>0)
5555 {
5556 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5557 move -= thismove;
5558 hitdir = kb_dir;
5559 switch(kb_dir)
5560 {
5561 case r_up:
5562 case l_up:
5563 case up:
5564 y-=thismove;
5565 break;
5566
5567 case r_down:
5568 case l_down:
5569 case down:
5570 y+=thismove;
5571 break;
5572 }
5573 switch(kb_dir)
5574 {
5575 case l_up:
5576 case l_down:
5577 case left:
5578 x-=thismove;
5579 break;
5580
5581 case r_up:
5582 case r_down:
5583 case right:
5584 x+=thismove;
5585 break;
5586 }
5587 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5588 {
5589 if(!canmove(kb_dir,(zfix)0,0,true))
5590 {
5591 script_knockback_clk=0;
5592 clk3=0;
5593 //Fix to grid
5594 switch(kb_dir)
5595 {
5596 case up:
5597 case down:
5598 break;
5599 default:
5600 if(x < 0)
5601 x = 0;
5602 else if((int32_t(x)&15) > 7)
5603 x = TRUNCATE_TILE(int32_t(x)) + 16;
5604 else
5605 x = TRUNCATE_TILE(int32_t(x));
5606 break;
5607 }
5608 switch(kb_dir)
5609 {
5610 case left:
5611 case right:
5612 break;
5613 default:
5614 if(y < 0)
5615 y = 0;
5616 else if((int32_t(y)&15) > 7)
5617 y = TRUNCATE_TILE(int32_t(y)) + 16;
5618 else
5619 y = TRUNCATE_TILE(int32_t(y));
5620 break;
5621 }
5622 break;
5623 }
5624 }
5625 else
5626 {
5627 if(!scr_canplace(x,y,0,true))
5628 {
5629 script_knockback_clk=0;
5630 clk3=0;
5631 //Fix to grid
5632 if (OFFGRID_ENEMY)
5633 {
5634 switch(kb_dir)
5635 {
5636 case up:
5637 case down:
5638 break;
5639 default:
5640 if(x < 0)
5641 x = 0;
5642 else if((int32_t(x)&7) > 3)
5643 x = TRUNCATE_HALF_TILE(int32_t(x)) + 8;
5644 else
5645 x = TRUNCATE_HALF_TILE(int32_t(x));
5646 break;
5647 }
5648 switch(kb_dir)
5649 {
5650 case left:
5651 case right:
5652 break;
5653 default:
5654 if(y < 0)
5655 y = 0;
5656 else if((int32_t(y)&7) > 3)
5657 y = TRUNCATE_HALF_TILE(int32_t(y)) + 8;
5658 else
5659 y = TRUNCATE_HALF_TILE(int32_t(y));
5660 break;
5661 }
5662 }
5663 else
5664 {
5665 switch(kb_dir)
5666 {
5667 case up:
5668 case down:
5669 break;
5670 default:
5671 if(x < 0)
5672 x = 0;
5673 else if((int32_t(x)&15) > 7)
5674 x = TRUNCATE_TILE(int32_t(x)) + 16;
5675 else
5676 x = TRUNCATE_TILE(int32_t(x));
5677 break;
5678 }
5679 switch(kb_dir)
5680 {
5681 case left:
5682 case right:
5683 break;
5684 default:
5685 if(y < 0)
5686 y = 0;
5687 else if((int32_t(y)&15) > 7)
5688 y = TRUNCATE_TILE(int32_t(y)) + 16;
5689 else
5690 y = TRUNCATE_TILE(int32_t(y));
5691 break;
5692 }
5693 }
5694 break;
5695 }
5696
5697 }
5698 }
5699 return true;
5700 37982322 }
5701 // changes enemy's direction, checking restrictions
5702 // rate: 0 = no random changes, 16 = always random change
5703 // homing: 0 = none, 256 = always
5704 // grumble 0 = none, 4 = strongest appetite
5705 520987 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5706 {
5707 520987 int32_t ndir=-1;
5708
5709
4/4
✓ Branch 0 taken 110050 times.
✓ Branch 1 taken 410937 times.
✓ Branch 2 taken 37872 times.
✓ Branch 3 taken 72178 times.
520987 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble))
5710 {
5711 72178 int32_t i = Lwpns.idFirst(wBait);
5712
1/2
✓ Branch 0 taken 72178 times.
✗ Branch 1 not taken.
72178 if(i >= 0) //idfirst returns -1 if it can't find any
5713 {
5714 weapon *w = (weapon*)Lwpns.spr(i);
5715 if (get_qr(qr_FIND_CLOSEST_BAIT))
5716 {
5717 int32_t currentrange;
5718 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5719 else currentrange = -1;
5720 int curid = i;
5721 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5722 for(; i<Lwpns.Count(); ++i)
5723 {
5724 weapon *lw = (weapon*)Lwpns.spr(i);
5725 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5726 {
5727 currentrange = distance(x, y, lw->x, lw->y);
5728 curid = i;
5729 }
5730 }
5731 i = curid;
5732 if (currentrange == -1) i = -1;
5733 }
5734 else
5735 {
5736 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5737 }
5738 if (i >= 0)
5739 {
5740 int32_t bx = Lwpns.spr(i)->x;
5741 int32_t by = Lwpns.spr(i)->y;
5742
5743 if(abs(int32_t(y)-by)>14)
5744 {
5745 ndir = (by<y) ? up : down;
5746 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5747 if(canmove(ndir,special,false))
5748 {
5749 dir=ndir;
5750 return;
5751 }
5752 }
5753
5754 ndir = (bx<x) ? left : right;
5755 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5756 if(canmove(ndir,special,false))
5757 {
5758 dir=ndir;
5759 return;
5760 }
5761 }
5762 }
5763 72178 }
5764
5765
2/2
✓ Branch 0 taken 352910 times.
✓ Branch 1 taken 168077 times.
520987 if((zc_oldrand()&255)<abs(newhoming))
5766 {
5767 168077 ndir = lined_up(8,false);
5768
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 168077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
168077 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5769
4/4
✓ Branch 0 taken 45378 times.
✓ Branch 1 taken 122699 times.
✓ Branch 2 taken 5717 times.
✓ Branch 3 taken 39661 times.
168077 if(ndir>=0 && canmove(ndir,special,false))
5770 {
5771 39661 dir=ndir;
5772 39661 return;
5773 }
5774 128416 }
5775
5776 481326 int32_t i=0;
5777
5778
2/2
✓ Branch 0 taken 3339 times.
✓ Branch 1 taken 1180920 times.
1184259 for(; i<32; i++)
5779 {
5780 1180920 int32_t r=zc_oldrand();
5781
5782
2/2
✓ Branch 0 taken 345075 times.
✓ Branch 1 taken 835845 times.
1180920 if((r&15)<newrate)
5783 345075 ndir=(r>>4)&3;
5784 else
5785 835845 ndir=dir;
5786
5787
2/2
✓ Branch 0 taken 702933 times.
✓ Branch 1 taken 477987 times.
1180920 if(canmove(ndir,special,false))
5788 477987 break;
5789 702933 }
5790
5791
2/2
✓ Branch 0 taken 477987 times.
✓ Branch 1 taken 3339 times.
482083 if(i==32)
5792 {
5793
2/2
✓ Branch 0 taken 8935 times.
✓ Branch 1 taken 757 times.
9692 for(ndir=0; ndir<4; ndir++)
5794 {
5795
2/2
✓ Branch 0 taken 6353 times.
✓ Branch 1 taken 2582 times.
8935 if(canmove(ndir,special,false))
5796 2582 goto ok;
5797 6353 }
5798
5799
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 697 times.
757 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5800 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5801 757 }
5802
5803 ok:
5804 481326 dir = ndir;
5805 520987 }
5806
5807 2682 void enemy::newdir()
5808 {
5809 2682 newdir(4,0,spw_none);
5810 2682 }
5811
5812 zfix enemy::distance_left()
5813 {
5814 int32_t a2=x.getInt();
5815 int32_t b2=y.getInt();
5816
5817 switch(dir)
5818 {
5819 case up:
5820 return (zfix)(b2&0xF);
5821
5822 case down:
5823 return (zfix)(16-(b2&0xF));
5824
5825 case left:
5826 return (zfix)(a2&0xF);
5827
5828 case right:
5829 return (zfix)(16-(a2&0xF));
5830 }
5831
5832 return (zfix)0;
5833 }
5834
5835 // keeps walking around
5836 391434 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5837 {
5838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391434 times.
391434 if(slide())
5839 return;
5840
5841
8/12
✓ Branch 0 taken 387600 times.
✓ Branch 1 taken 3834 times.
✓ Branch 2 taken 387600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 383173 times.
✓ Branch 5 taken 4427 times.
✓ Branch 6 taken 383173 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 383173 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 383173 times.
391434 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5842 8261 return;
5843
5844
2/2
✓ Branch 0 taken 26115 times.
✓ Branch 1 taken 357058 times.
383173 if(clk3<=0)
5845 {
5846 26115 fix_coords(true);
5847 26115 newdir(newrate,newhoming,special);
5848
5849
1/2
✓ Branch 0 taken 26115 times.
✗ Branch 1 not taken.
26115 if(step==0)
5850 clk3=0;
5851 else
5852 26115 clk3=int32_t(16.0/step);
5853 26115 }
5854
2/2
✓ Branch 0 taken 357013 times.
✓ Branch 1 taken 45 times.
357058 else if(scored)
5855 {
5856 45 dir^=1;
5857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5858 else clk3=32767;
5859 45 }
5860
5861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383173 times.
383173 if (step != 0) --clk3;
5862 383173 move(step);
5863 391434 }
5864
5865 void enemy::constant_walk()
5866 {
5867 constant_walk(4,0,spw_none);
5868 }
5869
5870 35220 int32_t enemy::pos(int32_t newx,int32_t newy)
5871 {
5872 35220 return (newy<<8)+newx;
5873 }
5874
5875 // for variable step rates
5876 473814 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5877 {
5878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
473814 if(slide())
5879 return;
5880
5881
10/14
✓ Branch 0 taken 473814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 473814 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 465189 times.
✓ Branch 5 taken 8625 times.
✓ Branch 6 taken 455915 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 418370 times.
✓ Branch 9 taken 37545 times.
✓ Branch 10 taken 418370 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 418370 times.
✗ Branch 13 not taken.
473814 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5882 55444 return;
5883
5884 418370 zfix dx = (zfix)0;
5885 418370 zfix dy = (zfix)0;
5886
5887
5/9
✓ Branch 0 taken 93441 times.
✓ Branch 1 taken 97752 times.
✓ Branch 2 taken 111603 times.
✓ Branch 3 taken 113743 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1831 times.
418370 switch(dir)
5888 {
5889 case 8:
5890 case up:
5891 93441 dy-=step;
5892 93441 break;
5893
5894 case 12:
5895 case down:
5896 97752 dy+=step;
5897 97752 break;
5898
5899 case 14:
5900 case left:
5901 111603 dx-=step;
5902 111603 break;
5903
5904 case 10:
5905 case right:
5906 113743 dx+=step;
5907 113743 break;
5908
5909 case 15:
5910 case l_up:
5911 dx-=step;
5912 dy-=step;
5913 break;
5914
5915 case 9:
5916 case r_up:
5917 dx+=step;
5918 dy-=step;
5919 break;
5920
5921 case 13:
5922 case l_down:
5923 dx-=step;
5924 dy+=step;
5925 break;
5926
5927 case 11:
5928 case r_down:
5929 dx+=step;
5930 dy+=step;
5931 break;
5932 }
5933
5934
8/8
✓ Branch 0 taken 204198 times.
✓ Branch 1 taken 214172 times.
✓ Branch 2 taken 22777 times.
✓ Branch 3 taken 181421 times.
✓ Branch 4 taken 11556 times.
✓ Branch 5 taken 11221 times.
✓ Branch 6 taken 405927 times.
✓ Branch 7 taken 12443 times.
418370 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5935 406814 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5936 {
5937 12443 fix_coords();
5938 12443 newdir(newrate,newhoming,special);
5939 12443 clk3=pos(x,y);
5940 12443 }
5941
5942 418370 move(step);
5943 473814 }
5944
5945 // pauses for a while after it makes a complete move (to a new square)
5946 12331419 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5947 {
5948
4/4
✓ Branch 0 taken 79890 times.
✓ Branch 1 taken 12251529 times.
✓ Branch 2 taken 67058 times.
✓ Branch 3 taken 12832 times.
12331419 if(sclk && clk2)
5949 {
5950 12832 clk3=0;
5951 12832 }
5952
5953
11/14
✓ Branch 0 taken 12258395 times.
✓ Branch 1 taken 73024 times.
✓ Branch 2 taken 12258395 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12258395 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11791227 times.
✓ Branch 7 taken 467168 times.
✓ Branch 8 taken 11653478 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 11648942 times.
✓ Branch 11 taken 4536 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 11648942 times.
12331419 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5954 {
5955 682477 return;
5956 }
5957
5958
2/2
✓ Branch 0 taken 2132811 times.
✓ Branch 1 taken 9516131 times.
11648942 if(clk2>0)
5959 {
5960 2132811 --clk2;
5961 2132811 return;
5962 }
5963
5964
2/2
✓ Branch 0 taken 411156 times.
✓ Branch 1 taken 9104975 times.
9516131 if(clk3<=0)
5965 {
5966 411156 fix_coords(true);
5967 411156 newdir(newrate,newhoming,special);
5968 411156 clk3=int32_t(16.0/step);
5969
2/2
✓ Branch 0 taken 410959 times.
✓ Branch 1 taken 197 times.
411156 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 411156 times.
411156 if(clk2<0)
5971 {
5972 clk2=0;
5973 }
5974
2/2
✓ Branch 0 taken 54768 times.
✓ Branch 1 taken 356388 times.
411156 else if((zc_oldrand()&15)<newhrate)
5975 {
5976 54768 clk2=haltcnt;
5977 54768 return;
5978 }
5979 356388 }
5980
2/2
✓ Branch 0 taken 9101816 times.
✓ Branch 1 taken 3159 times.
9104975 else if(scored)
5981 {
5982 3159 dir^=1;
5983
5984
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3154 times.
3159 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5985 5 else clk3=32767;
5986 3159 }
5987
5988
2/2
✓ Branch 0 taken 76939 times.
✓ Branch 1 taken 9384424 times.
9461363 if (step != 0) --clk3;
5989 9461363 move(step);
5990 12331419 }
5991
5992 // 8-directional movement, aligns to 8 pixels
5993 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5994 {
5995 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5996 return;
5997
5998 if(clk3<=0)
5999 {
6000 newdir_8(newrate,newhoming,special);
6001 clk3=int32_t(8.0/step);
6002 if (step == 0) clk3 = 32767;
6003 }
6004
6005 if (step != 0) --clk3;
6006 move(step);
6007 }
6008 // 8-directional movement, aligns to 8 pixels
6009 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6010 {
6011
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6012 return;
6013
6014
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
6015 {
6016 16235 newdir_8(newrate,newhoming,special);
6017 16235 clk3=int32_t(8.0/step);
6018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6019 16235 }
6020
6021
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6022 242393 move(step);
6023 242393 }
6024
6025 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6026 {
6027 if(clk<0 || dying || stunclk || watch || frozenclock)
6028 return;
6029
6030 if(!canmove(dir,step,special,false))
6031 clk3=0;
6032
6033 if(clk2>0)
6034 {
6035 --clk2;
6036 return;
6037 }
6038
6039 if(clk3<=0)
6040 {
6041 newdir_8(newrate,newhoming,special);
6042 clk3=newclk;
6043
6044 if(clk2<0)
6045 {
6046 clk2=0;
6047 }
6048 else if((zc_oldrand()&15)<newhrate)
6049 {
6050 newdir_8(newrate,newhoming,special);
6051 clk2=haltcnt;
6052 return;
6053 }
6054 }
6055
6056 --clk3;
6057 move(step);
6058 }
6059
6060 // 8-directional movement, no alignment
6061 4721045 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6062 {
6063
9/12
✓ Branch 0 taken 4511760 times.
✓ Branch 1 taken 209285 times.
✓ Branch 2 taken 4511760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4485139 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4474092 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4474092 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4474092 times.
4721045 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6064 246953 return;
6065
6066
2/2
✓ Branch 0 taken 4443604 times.
✓ Branch 1 taken 30488 times.
4474092 if(!canmove(dir,step,special,false))
6067 30488 clk3=0;
6068
6069
2/2
✓ Branch 0 taken 3916074 times.
✓ Branch 1 taken 558018 times.
4474092 if(clk3<=0)
6070 {
6071 558018 newdir_8(newrate,newhoming,special);
6072 558018 clk3=newclk;
6073 558018 }
6074
6075 4474092 --clk3;
6076 4474092 move(step);
6077 4721045 }
6078
6079 // same as above but with variable enemy size
6080 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6081 {
6082
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6083 1247 return;
6084
6085
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6086 1334 clk3=0;
6087
6088
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6089 {
6090 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6091 6475 clk3=newclk;
6092 6475 }
6093
6094 93316 --clk3;
6095 93316 move(step);
6096 94563 }
6097
6098 // the variable speed floater movement
6099 // ms is max speed
6100 // ss is step speed
6101 // s is step count
6102 // p is pause count
6103 // g is graduality :)
6104 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6105 4019514 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6106 {
6107 4019514 ++clk2;
6108 4019514 byte over_pit = overpit(this);
6109
6110
4/4
✓ Branch 0 taken 1114794 times.
✓ Branch 1 taken 2904720 times.
✓ Branch 2 taken 1114527 times.
✓ Branch 3 taken 267 times.
4019514 if(dmisc1 && over_pit) p = 0;
6111
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 56650 times.
✓ Branch 2 taken 1586380 times.
✓ Branch 3 taken 2243416 times.
✓ Branch 4 taken 133068 times.
4019514 switch(movestatus)
6112 {
6113 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6114 //! if the conditions prevent it, we jump back to case 2.
6115 case 0: // paused
6116
2/2
✓ Branch 0 taken 55199 times.
✓ Branch 1 taken 1451 times.
56650 if(clk2>=p)
6117 {
6118 1451 movestatus=1;
6119 1451 clk2=0;
6120 1451 }
6121
6122 56650 break;
6123
6124 case 1: // speeding up
6125
1/2
✓ Branch 0 taken 1586380 times.
✗ Branch 1 not taken.
1586380 if (s >= 0)
6126 {
6127
2/2
✓ Branch 0 taken 1575074 times.
✓ Branch 1 taken 11306 times.
1586380 if(clk2<g*s)
6128 {
6129
2/2
✓ Branch 0 taken 1473474 times.
✓ Branch 1 taken 101600 times.
1575074 if(!((clk2-1)%g))
6130 101600 step+=ss;
6131 1575074 }
6132 else
6133 {
6134 11306 movestatus=2;
6135 11306 clk2=0;
6136 }
6137 1586380 }
6138 else
6139 {
6140 if(step < ms)
6141 {
6142 if(!((clk2-1)%g))
6143 {
6144 step+=ss;
6145 if (step >= ms) step = ms;
6146 }
6147 }
6148 else
6149 {
6150 step = ms;
6151 movestatus=2;
6152 clk2=0;
6153 }
6154 }
6155
6156 1586380 break;
6157
6158 case 2: // normal
6159 2243416 step=ms;
6160
6161
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2243416 times.
✓ Branch 2 taken 481019 times.
✓ Branch 3 taken 1762397 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1762397 times.
✓ Branch 6 taken 1760147 times.
✓ Branch 7 taken 2250 times.
2243416 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6162 {
6163
1/2
✓ Branch 0 taken 2250 times.
✗ Branch 1 not taken.
2250 if (s >= 0) step=ss*s;
6164 else step=ms;
6165 2250 movestatus=3;
6166 2250 clk2=0;
6167 2250 }
6168
6169 2243416 break;
6170
6171 case 3: // slowing down
6172
1/2
✓ Branch 0 taken 133068 times.
✗ Branch 1 not taken.
133068 if (s >= 0)
6173 {
6174
2/2
✓ Branch 0 taken 131387 times.
✓ Branch 1 taken 1681 times.
133068 if(clk2<=g*s)
6175 {
6176 { //don't slow down over pits
6177
6178
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 131120 times.
131387 if(over_pit)
6179 {
6180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 if(dmisc1)
6181 {
6182 step=ms;
6183 }
6184 267 }
6185 else //can slow down
6186 {
6187
4/4
✓ Branch 0 taken 8088 times.
✓ Branch 1 taken 123032 times.
✓ Branch 2 taken 7720 times.
✓ Branch 3 taken 368 times.
131120 if(!(clk2%g) && !dmisc1)
6188 7720 step-=ss;
6189 }
6190 }
6191
6192
6193 131387 }
6194 else
6195 {
6196 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6197 //this doesn't help keese, as they have a z of 0.
6198 //they always nee to run this check.
6199 {
6200
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1681 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1681 if(over_pit &&!dmisc1)
6201 {
6202 --clk2; //if over a pit, don't land, and revert clock change
6203 }
6204 else //can land safely
6205 {
6206 1681 movestatus=0;
6207
3/4
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 566 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1115 times.
1681 if(dmisc1&&!over_pit)
6208 1115 step=0;
6209 1681 clk2=0;
6210 }
6211 }
6212
6213 }
6214 133068 }
6215 else
6216 {
6217 if(step > 0)
6218 {
6219 if(over_pit)
6220 {
6221 if(dmisc1)
6222 {
6223 step=ms;
6224 }
6225 }
6226 else //can slow down
6227 {
6228 if(!(clk2%g))
6229 step-=ss;
6230 }
6231 }
6232 else
6233 {
6234 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6235 //this doesn't help keese, as they have a z of 0.
6236 //they always nee to run this check.
6237 if(over_pit)
6238 {
6239 step+=ss; //if over a pit, don't land, and revert clock change
6240 }
6241 else //can land safely
6242 {
6243 movestatus=0;
6244 step=0;
6245 clk2=0;
6246 }
6247 }
6248 }
6249
6250 133068 break;
6251 }
6252
6253
2/2
✓ Branch 0 taken 2252472 times.
✓ Branch 1 taken 1767042 times.
4019514 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6254 4019514 }
6255
6256 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6257 {
6258 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6259 }
6260
6261 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6262 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6263 927902 int32_t enemy::lined_up(int32_t range, bool dir8)
6264 {
6265 927902 int32_t lx = Hero.getX();
6266 927902 int32_t ly = Hero.getY();
6267
6268
2/2
✓ Branch 0 taken 38909 times.
✓ Branch 1 taken 888993 times.
927902 if(abs(lx-int32_t(x))<=range)
6269 {
6270
2/2
✓ Branch 0 taken 16349 times.
✓ Branch 1 taken 22560 times.
38909 if(ly<y)
6271 {
6272 16349 return up;
6273 }
6274
6275 22560 return down;
6276 }
6277
6278
2/2
✓ Branch 0 taken 56354 times.
✓ Branch 1 taken 832639 times.
888993 if(abs(ly-int32_t(y))<=range)
6279 {
6280
2/2
✓ Branch 0 taken 30296 times.
✓ Branch 1 taken 26058 times.
56354 if(lx<x)
6281 {
6282 30296 return left;
6283 }
6284
6285 26058 return right;
6286 }
6287
6288
2/2
✓ Branch 0 taken 160049 times.
✓ Branch 1 taken 672590 times.
832639 if(dir8)
6289 {
6290
2/2
✓ Branch 0 taken 253848 times.
✓ Branch 1 taken 418742 times.
672590 if(abs(lx-x)-abs(ly-y)<=range)
6291 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6292 {
6293
2/2
✓ Branch 0 taken 106080 times.
✓ Branch 1 taken 147768 times.
253848 if(ly<y)
6294 {
6295
2/2
✓ Branch 0 taken 56676 times.
✓ Branch 1 taken 49404 times.
106080 if(lx<x)
6296 {
6297 56676 return l_up;
6298 }
6299 else
6300 {
6301 49404 return r_up;
6302 }
6303 }
6304 else
6305 {
6306
2/2
✓ Branch 0 taken 76696 times.
✓ Branch 1 taken 71072 times.
147768 if(lx<x)
6307 {
6308 71072 return l_down;
6309 }
6310 else
6311 {
6312 76696 return r_down;
6313 }
6314 }
6315 }
6316 418742 }
6317
6318 578791 return -1;
6319 927902 }
6320
6321 // returns true if Hero is within 'range' pixels of the enemy
6322 27884 bool enemy::HeroInRange(int32_t range)
6323 {
6324 27884 int32_t lx = Hero.getX();
6325 27884 int32_t ly = Hero.getY();
6326
2/2
✓ Branch 0 taken 22775 times.
✓ Branch 1 taken 5109 times.
27884 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6327 }
6328
6329 // place the enemy in line with Hero (red wizzrobes)
6330 4899 void enemy::place_on_axis(bool floater, bool solid_ok)
6331 {
6332
6/6
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 4312 times.
✓ Branch 2 taken 4355 times.
✓ Branch 3 taken 544 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 3768 times.
4899 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6333
6/6
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 4460 times.
✓ Branch 2 taken 4109 times.
✓ Branch 3 taken 790 times.
✓ Branch 4 taken 439 times.
✓ Branch 5 taken 3670 times.
4899 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6334 4899 int32_t pos2=zc_oldrand()%23;
6335 4899 int32_t tried=0;
6336 4899 bool last_resort,placed=false;
6337
6338
6339 4899 do
6340 {
6341
2/2
✓ Branch 0 taken 4460 times.
✓ Branch 1 taken 3127 times.
7587 if(pos2<14)
6342 {
6343 4460 x=(pos2<<4)+16;
6344 4460 y=ly;
6345 4460 }
6346 else
6347 {
6348 3127 x=lx;
6349 3127 y=((pos2-14)<<4)+16;
6350 }
6351
6352 // Don't commit to a last resort if position is out of bounds.
6353
6/6
✓ Branch 0 taken 7248 times.
✓ Branch 1 taken 339 times.
✓ Branch 2 taken 6936 times.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 257 times.
✓ Branch 5 taken 6679 times.
7587 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6354
6355
4/4
✓ Branch 0 taken 3907 times.
✓ Branch 1 taken 3680 times.
✓ Branch 2 taken 4862 times.
✓ Branch 3 taken 1311 times.
7587 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6356 {
6357 // Red Wizzrobes should be able to appear on water, but not other
6358 // solid combos; however, they could appear on solid combos in 2.10,
6359 // and some quests depend on that.
6360
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6201 times.
✓ Branch 2 taken 1302 times.
✓ Branch 3 taken 4899 times.
8542 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6361 8542 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6362 4899 placed=true;
6363 8542 }
6364
6365
3/6
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4561 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2688 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7249 if(!placed && tried>=22 && last_resort)
6366 {
6367 placed=true;
6368 }
6369
6370 7249 ++tried;
6371 7249 pos2=(pos2+3)%23;
6372
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4561 times.
7249 }
6373 7249 while(!placed);
6374
6375
2/2
✓ Branch 0 taken 2753 times.
✓ Branch 1 taken 1808 times.
4561 if(y==ly)
6376 2753 dir=(x<lx)?right:left;
6377 else
6378 1808 dir=(y<ly)?down:up;
6379
6380 4561 clk2=tried;
6381 4561 }
6382
6383 20334859 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6384 {
6385 20334859 int32_t t = o_tile;
6386 20334859 int32_t b = o_tile;
6387
6388 // Darknuts, but also Wizzrobes and Wallmasters
6389
3/4
✓ Branch 0 taken 8417552 times.
✓ Branch 1 taken 10877537 times.
✓ Branch 2 taken 1039770 times.
✗ Branch 3 not taken.
20334859 switch(family)
6390 {
6391 case eeWALK:
6392
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10372130 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
10877537 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6393 {
6394 367468 tile=s_tile;
6395 367468 t=s_tile;
6396 367468 b=s_tile;
6397 367468 }
6398
6399 10877537 break;
6400
6401 case eeTRAP:
6402
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 846204 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1039770 if(dummy_int[1] && guysbuf[id].flags & guy_trp2 && do_animation) // Just to make sure
6403 {
6404 193566 tile=s_tile;
6405 193566 t=s_tile;
6406 193566 b=s_tile;
6407 193566 }
6408
6409 1039770 break;
6410
6411 case eeSPINTILE:
6412 if(misc>=96 && do_animation)
6413 {
6414 tile=o_tile+frames*ndir;
6415 t=tile;
6416 }
6417
6418 break;
6419 }
6420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20334859 times.
20334859 if ( do_animation )
6421 {
6422
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 20137817 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19870686 times.
20334859 if(ndir!=0) switch(frames)
6423 {
6424 case 2:
6425 267131 tiledir_small(dir,ndir==4);
6426 267131 break;
6427
6428 case 3:
6429 tiledir_three(dir);
6430 break;
6431
6432 case 4:
6433 19870686 tiledir(dir,ndir==4);
6434 19870686 break;
6435 20137817 }
6436
6437
2/2
✓ Branch 0 taken 10877537 times.
✓ Branch 1 taken 9457322 times.
20334859 if(family==eeWALK)
6438
6/6
✓ Branch 0 taken 10816528 times.
✓ Branch 1 taken 61009 times.
✓ Branch 2 taken 8211367 times.
✓ Branch 3 taken 2666170 times.
✓ Branch 4 taken 2650447 times.
✓ Branch 5 taken 15723 times.
10877537 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6439 else
6440 9457322 tile+=f4;
6441 20334859 }
6442 20334859 return b;
6443 }
6444
6445 void enemy::tiledir_three(int32_t ndir)
6446 {
6447 if ( !do_animation ) return;
6448 flip=0;
6449
6450 switch(ndir)
6451 {
6452 case right:
6453 tile+=3;
6454 [[fallthrough]];
6455
6456 case left:
6457 tile+=3;
6458 [[fallthrough]];
6459
6460 case down:
6461 tile+=3;
6462 [[fallthrough]];
6463
6464 case up:
6465 break;
6466 }
6467 }
6468
6469 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6470 {
6471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6472 267131 flip=0;
6473
6474
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6475 {
6476 case 8:
6477 case up:
6478 53829 break;
6479
6480 case 12:
6481 case down:
6482 54679 tile+=2;
6483 54679 break;
6484
6485 case 14:
6486 case left:
6487 67727 tile+=4;
6488 67727 break;
6489
6490 case 10:
6491 case right:
6492 71182 tile+=6;
6493 71182 break;
6494
6495 case 9:
6496 case r_up:
6497
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6498 5706 break;
6499
6500 tile+=10;
6501 break;
6502
6503 case 11:
6504 case r_down:
6505
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6506 5154 tile+=2;
6507 else
6508 tile+=14;
6509
6510 5154 break;
6511
6512 case 13:
6513 case l_down:
6514
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6515 4872 tile+=2;
6516 else
6517 tile+=12;
6518
6519 4872 break;
6520
6521 case 15:
6522 case l_up:
6523
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6524 3982 break;
6525
6526 tile+=8;
6527 break;
6528
6529 default:
6530 //dir=(zc_oldrand()*100)%8;
6531 //tiledir_small(dir);
6532 // flip=zc_oldrand()&3;
6533 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6534 break;
6535 }
6536 267131 }
6537
6538 23203434 void enemy::tiledir(int32_t ndir, bool fourdir)
6539 {
6540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23203434 times.
23203434 if ( !do_animation ) return;
6541 23203434 flip=0;
6542
6543
9/9
✓ Branch 0 taken 4509460 times.
✓ Branch 1 taken 4163411 times.
✓ Branch 2 taken 5444983 times.
✓ Branch 3 taken 5198041 times.
✓ Branch 4 taken 834140 times.
✓ Branch 5 taken 1027612 times.
✓ Branch 6 taken 1106457 times.
✓ Branch 7 taken 852481 times.
✓ Branch 8 taken 66849 times.
23203434 switch(ndir)
6544 {
6545 case 8:
6546 case up:
6547 4509460 break;
6548
6549 case 12:
6550 case down:
6551 4163411 tile+=4;
6552 4163411 break;
6553
6554 case 14:
6555 case left:
6556 5444983 tile+=8;
6557 5444983 break;
6558
6559 case 10:
6560 case right:
6561 5198041 tile+=12;
6562 5198041 break;
6563
6564 case 9:
6565 case r_up:
6566
2/2
✓ Branch 0 taken 89257 times.
✓ Branch 1 taken 744883 times.
834140 if(fourdir)
6567 89257 break;
6568 else
6569 744883 tile+=24;
6570
6571 744883 break;
6572
6573 case 11:
6574 case r_down:
6575
2/2
✓ Branch 0 taken 102657 times.
✓ Branch 1 taken 924955 times.
1027612 if(fourdir)
6576 102657 tile+=4;
6577 else
6578 924955 tile+=32;
6579
6580 1027612 break;
6581
6582 case 13:
6583 case l_down:
6584
2/2
✓ Branch 0 taken 106171 times.
✓ Branch 1 taken 1000286 times.
1106457 if(fourdir)
6585 106171 tile+=4;
6586 else
6587 1000286 tile+=28;
6588
6589 1106457 break;
6590
6591 case 15:
6592 case l_up:
6593
2/2
✓ Branch 0 taken 82882 times.
✓ Branch 1 taken 769599 times.
852481 if(fourdir)
6594 82882 break;
6595 else
6596 769599 tile+=20;
6597
6598 769599 break;
6599
6600 default:
6601 //dir=(zc_oldrand()*100)%8;
6602 //tiledir(dir);
6603 // flip=zc_oldrand()&3;
6604 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6605 66849 break;
6606 }
6607 23203434 }
6608
6609 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6610 {
6611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6612 3868 flip=0;
6613
6614
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6615 {
6616 case 8:
6617 case up:
6618 297 break;
6619
6620 case 12:
6621 case down:
6622 tile+=8;
6623 break;
6624
6625 case 14:
6626 case left:
6627 195 tile+=40;
6628 195 break;
6629
6630 case 10:
6631 case right:
6632 179 tile+=48;
6633 179 break;
6634
6635 case 9:
6636 case r_up:
6637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6638 break;
6639
6640 306 tile+=88;
6641 306 break;
6642
6643 case 11:
6644 case r_down:
6645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6646 tile+=8;
6647 else
6648 1235 tile+=128;
6649
6650 1235 break;
6651
6652 case 13:
6653 case l_down:
6654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6655 tile+=8;
6656 else
6657 1324 tile+=120;
6658
6659 1324 break;
6660
6661 case 15:
6662 case l_up:
6663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6664 break;
6665
6666 332 tile+=80;
6667 332 break;
6668
6669 default:
6670 //dir=(zc_oldrand()*100)%8;
6671 //tiledir_big(dir);
6672 // flip=zc_oldrand()&3;
6673 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6674 break;
6675 }
6676 3868 }
6677
6678 40135036 void enemy::update_enemy_frame()
6679 {
6680
4/4
✓ Branch 0 taken 40132661 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 40132654 times.
40135036 if(fallclk||drownclk) return;
6681
1/2
✓ Branch 0 taken 40132654 times.
✗ Branch 1 not taken.
40132654 if (!do_animation)
6682 return;
6683
6684
4/4
✓ Branch 0 taken 1549143 times.
✓ Branch 1 taken 38583511 times.
✓ Branch 2 taken 1547136 times.
✓ Branch 3 taken 2007 times.
40132654 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6685
6686
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
40132654 if(get_qr(qr_ANONE_NOANIM)
6687
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40132654 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40132654 && anim == aNONE && family != eeGUY)
6688 return;
6689
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 39761278 times.
40132654 int32_t newfrate = zc_max(frate,4);
6690 40132654 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6691 40132654 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6692
2/2
✓ Branch 0 taken 30139007 times.
✓ Branch 1 taken 9993647 times.
40132654 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6693 40132654 tile = o_tile;
6694 40132654 int32_t basetile = o_tile;
6695 40132654 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6696 40132654 bool ignore_extend = false;
6697
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 209083 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 363745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 5072121 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 53456 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1525813 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 693272 times.
✓ Branch 22 taken 1692048 times.
✓ Branch 23 taken 1134909 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4134380 times.
✓ Branch 27 taken 7515986 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582937 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880176 times.
✓ Branch 32 taken 219096 times.
✓ Branch 33 taken 1818304 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 7018408 times.
✓ Branch 37 taken 747030 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 171508 times.
40132654 switch(anim)
6698 {
6699
6700 case aDONGO:
6701 {
6702 69324 int32_t fr = stunclk>0 ? 16 : 8;
6703
6704
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6705 {
6706 // bloated
6707
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6708 {
6709 case up:
6710 960 tile+=9;
6711 960 flip=0;
6712 960 xofs=0;
6713 960 dummy_int[1]=0; //no additional tiles
6714 960 break;
6715
6716 case down:
6717 960 tile+=7;
6718 960 flip=0;
6719 960 xofs=0;
6720 960 dummy_int[1]=0; //no additional tiles
6721 960 break;
6722
6723 case left:
6724 1664 flip=1;
6725 1664 tile+=4;
6726 1664 xofs=16;
6727 1664 dummy_int[1]=1; //second tile is next tile
6728 1664 break;
6729
6730 case right:
6731 896 flip=0;
6732 896 tile+=5;
6733 896 xofs=16;
6734 896 dummy_int[1]=-1; //second tile is previous tile
6735 896 break;
6736 }
6737 4480 }
6738
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6739 {
6740 // normal
6741
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6742 {
6743 case up:
6744 13652 tile+=8;
6745 13652 flip=(clk&fr)?1:0;
6746 13652 xofs=0;
6747 13652 dummy_int[1]=0; //no additional tiles
6748 13652 break;
6749
6750 case down:
6751 15374 tile+=6;
6752 15374 flip=(clk&fr)?1:0;
6753 15374 xofs=0;
6754 15374 dummy_int[1]=0; //no additional tiles
6755 15374 break;
6756
6757 case left:
6758 19615 flip=1;
6759 19615 tile+=(clk&fr)?2:0;
6760 19615 xofs=16;
6761 19615 dummy_int[1]=1; //second tile is next tile
6762 19615 break;
6763
6764 case right:
6765 15086 flip=0;
6766 15086 tile+=(clk&fr)?3:1;
6767 15086 xofs=16;
6768 15086 dummy_int[1]=-1; //second tile is next tile
6769 15086 break;
6770 }
6771 63727 }
6772 }
6773 69324 break;
6774
6775 case aNEWDONGO:
6776 {
6777 53456 int32_t fr4=0;
6778
6779
6/6
✓ Branch 0 taken 51564 times.
✓ Branch 1 taken 1892 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 47436 times.
✓ Branch 4 taken 1376 times.
✓ Branch 5 taken 2752 times.
53456 if(!dying && clk2>0 && clk2<=64)
6780 {
6781 // bloated
6782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2752 times.
2752 if(clk2>=0)
6783 {
6784 2752 fr4=3;
6785 2752 }
6786
6787
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 2107 times.
2752 if(clk2>=16)
6788 {
6789 2107 fr4=2;
6790 2107 }
6791
6792
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 1419 times.
2752 if(clk2>=32)
6793 {
6794 1419 fr4=1;
6795 1419 }
6796
6797
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 731 times.
2752 if(clk2>=48)
6798 {
6799 731 fr4=0;
6800 731 }
6801
6802
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1216 times.
2752 switch(dir)
6803 {
6804 case up:
6805 256 xofs=0;
6806 256 tile+=8+fr4;
6807 256 dummy_int[1]=0; //no additional tiles
6808 256 break;
6809
6810 case down:
6811 576 xofs=0;
6812 576 tile+=12+fr4;
6813 576 dummy_int[1]=0; //no additional tiles
6814 576 break;
6815
6816 case left:
6817 704 tile+=29+(2*fr4);
6818 704 xofs=16;
6819 704 dummy_int[1]=-1; //second tile is previous tile
6820 704 break;
6821
6822 case right:
6823 1216 tile+=49+(2*fr4);
6824 1216 xofs=16;
6825 1216 dummy_int[1]=-1; //second tile is previous tile
6826 1216 break;
6827 }
6828 2752 }
6829
4/4
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 48812 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 898 times.
50704 else if(!dying || clk2>19)
6830 {
6831 // normal
6832
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9234 times.
✓ Branch 2 taken 9871 times.
✓ Branch 3 taken 15025 times.
✓ Branch 4 taken 15676 times.
49806 switch(dir)
6833 {
6834 case up:
6835 9234 xofs=0;
6836 9234 tile+=((clk&12)>>2);
6837 9234 dummy_int[1]=0; //no additional tiles
6838 9234 break;
6839
6840 case down:
6841 9871 xofs=0;
6842 9871 tile+=4+((clk&12)>>2);
6843 9871 dummy_int[1]=0; //no additional tiles
6844 9871 break;
6845
6846 case left:
6847 15025 tile+=21+((clk&12)>>1);
6848 15025 xofs=16;
6849 15025 dummy_int[1]=-1; //second tile is previous tile
6850 15025 break;
6851
6852 case right:
6853 15676 flip=0;
6854 15676 tile+=41+((clk&12)>>1);
6855 15676 xofs=16;
6856 15676 dummy_int[1]=-1; //second tile is previous tile
6857 15676 break;
6858 }
6859 49806 }
6860 }
6861 53456 break;
6862
6863 case aDONGOBS:
6864 {
6865 38833 int32_t fr4=0;
6866
6867
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6868 {
6869 // bloated
6870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6871 {
6872 2688 fr4=3;
6873 2688 }
6874
6875
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6876 {
6877 2058 fr4=2;
6878 2058 }
6879
6880
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6881 {
6882 1386 fr4=1;
6883 1386 }
6884
6885
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6886 {
6887 714 fr4=0;
6888 714 }
6889
6890
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6891 {
6892 case up:
6893 256 tile+=28+fr4;
6894 256 yofs+=8;
6895 256 dummy_int[1]=-20; //second tile change
6896 256 dummy_int[2]=0; //new xofs change
6897 256 dummy_int[3]=-16; //new xofs change
6898 256 break;
6899
6900 case down:
6901 384 tile+=12+fr4;
6902 384 yofs-=8;
6903 384 dummy_int[1]=20; //second tile change
6904 384 dummy_int[2]=0; //new xofs change
6905 384 dummy_int[3]=16; //new xofs change
6906 384 break;
6907
6908 case left:
6909 1024 tile+=49+(2*fr4);
6910 1024 xofs+=8;
6911 1024 dummy_int[1]=-1; //second tile change
6912 1024 dummy_int[2]=-16; //new xofs change
6913 1024 dummy_int[3]=0; //new xofs change
6914 1024 break;
6915
6916 case right:
6917 1024 tile+=69+(2*fr4);
6918 1024 xofs+=8;
6919 1024 dummy_int[1]=-1; //second tile change
6920 1024 dummy_int[2]=-16; //new xofs change
6921 1024 dummy_int[3]=0; //new xofs change
6922 1024 break;
6923 }
6924 2688 }
6925
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6926 {
6927 // normal
6928
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6929 {
6930 case up:
6931 7136 tile+=20+((clk&24)>>3);
6932 7136 yofs+=8;
6933 7136 dummy_int[1]=-20; //second tile change
6934 7136 dummy_int[2]=0; //new xofs change
6935 7136 dummy_int[3]=-16; //new xofs change
6936 7136 break;
6937
6938 case down:
6939 6672 tile+=4+((clk&24)>>3);
6940 6672 yofs-=8;
6941 6672 dummy_int[1]=20; //second tile change
6942 6672 dummy_int[2]=0; //new xofs change
6943 6672 dummy_int[3]=16; //new xofs change
6944 6672 break;
6945
6946 case left:
6947 11075 xofs=-8;
6948 11075 tile+=40+((clk&24)>>2);
6949 11075 dummy_int[1]=1; //second tile change
6950 11075 dummy_int[2]=16; //new xofs change
6951 11075 dummy_int[3]=0; //new xofs change
6952 11075 break;
6953
6954 case right:
6955 10601 tile+=60+((clk&24)>>2);
6956 10601 xofs=-8;
6957 10601 dummy_int[1]=1; //second tile change
6958 10601 dummy_int[2]=16; //new xofs change
6959 10601 dummy_int[3]=0; //new xofs change
6960 10601 break;
6961 }
6962 35484 }
6963 }
6964 38833 break;
6965
6966 case aWIZZ:
6967 {
6968 // if(d->misc1)
6969
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6970 {
6971
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6972 {
6973 91127 ++tile;
6974 91127 }
6975 182184 }
6976 else
6977 {
6978
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6979 {
6980 136489 ++tile;
6981 136489 }
6982 }
6983
6984
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6985 {
6986 case 9:
6987 case 15:
6988 case up:
6989 76094 tile+=2;
6990 76094 break;
6991
6992 case down:
6993 76591 break;
6994
6995 case 13:
6996 case left:
6997 157108 flip=1;
6998 157108 break;
6999
7000 default:
7001 145581 flip=0;
7002 145581 break;
7003 }
7004 }
7005 455374 break;
7006
7007 case aNEWWIZZ:
7008 {
7009 1525813 tiledir(dir,true);
7010
7011 // if(d->misc1) //walking wizzrobe
7012
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 783389 times.
1525813 if(dmisc1) //walking wizzrobe
7013 {
7014
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
7015 {
7016 369103 tile+=2;
7017 369103 }
7018
7019
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7020 {
7021 370339 tile+=1;
7022 370339 }
7023
7024
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7025 {
7026
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7027 {
7028 79162 tile+=40;
7029 79162 }
7030 742424 }
7031 742424 }
7032 else
7033 {
7034
4/4
✓ Branch 0 taken 716244 times.
✓ Branch 1 taken 67145 times.
✓ Branch 2 taken 168827 times.
✓ Branch 3 taken 547417 times.
783389 if(dummy_bool[1]||dummy_bool[2])
7035 {
7036 235972 tile+=20;
7037
7038
2/2
✓ Branch 0 taken 67136 times.
✓ Branch 1 taken 168836 times.
235972 if(dummy_bool[2])
7039 {
7040 168836 tile+=20;
7041 168836 }
7042 235972 }
7043
7044 783389 tile+=((frame>>1)&3);
7045 }
7046 }
7047 1525813 break;
7048
7049 case a3FRM:
7050 {
7051
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7052 }
7053 197042 break;
7054
7055 case a3FRM4DIR:
7056 {
7057 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7058 }
7059 break;
7060
7061 case aVIRE:
7062 {
7063
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7064 {
7065 29292 tile+=2;
7066 29292 }
7067
7068 128880 tile+=fx;
7069 }
7070 128880 break;
7071
7072 case aROPE:
7073 {
7074 220021 tile+=(1-fx);
7075 220021 flip = dir==left ? 1:0;
7076 }
7077 220021 break;
7078
7079 case aZORA:
7080 {
7081 int32_t dl;
7082
7083
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7084 {
7085 46739 dl=clk+5;
7086 46739 goto waves2;
7087 }
7088
7089
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7090
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7091 else
7092 {
7093 92458 dl=clk-36-66;
7094 waves2:
7095 139197 tile=((dl/11)&1)+s_tile;
7096 139197 basetile = s_tile;
7097 }
7098 }
7099 221637 break;
7100
7101 case aNEWZORA:
7102 {
7103 693272 f4=(clk/16)%4;
7104
7105 693272 tiledir(dir,true);
7106 int32_t dl;
7107
7108
4/4
✓ Branch 0 taken 489980 times.
✓ Branch 1 taken 203292 times.
✓ Branch 2 taken 251304 times.
✓ Branch 3 taken 238676 times.
693272 if((clk>35)&&(clk<36+67)) //surfaced
7109 {
7110
4/4
✓ Branch 0 taken 204043 times.
✓ Branch 1 taken 34633 times.
✓ Branch 2 taken 29458 times.
✓ Branch 3 taken 174585 times.
238676 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7111 {
7112 174585 tile+=80;
7113 174585 } //mouth closed
7114 else
7115 {
7116 64091 tile+=40;
7117 }
7118
7119 238676 tile+=f4;
7120 238676 }
7121 else
7122 {
7123
2/2
✓ Branch 0 taken 203292 times.
✓ Branch 1 taken 251304 times.
454596 if(clk<36)
7124 {
7125 203292 dl=clk+5;
7126 203292 }
7127 else
7128 {
7129 251304 dl=clk-36-66;
7130 }
7131
7132 454596 tile+=((dl/5)&3);
7133 }
7134 }
7135 693272 break;
7136
7137 case a4FRM4EYE:
7138 case a2FRM4EYE:
7139 case a4FRM8EYE:
7140 case a4FRM8EYEB: //big version
7141 case a4FRM4EYEB:
7142 {
7143 836734 tilerows = 2;
7144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7146 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7147 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7148 836734 int32_t lookat=zc_oldrand()&15;
7149
7150
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7151 {
7152 210774 lookat=l_down;
7153 210774 }
7154
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7155 {
7156 226850 lookat=down;
7157 226850 }
7158
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7159 {
7160 108837 lookat=r_down;
7161 108837 }
7162
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7163 {
7164 70395 lookat=right;
7165 70395 }
7166
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7167 {
7168 35067 lookat=r_up;
7169 35067 }
7170
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7171 {
7172 25436 lookat=up;
7173 25436 }
7174
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7175 {
7176 36803 lookat=l_up;
7177 36803 }
7178 else
7179 {
7180 122572 lookat=left;
7181 }
7182
7183 836734 int32_t dir2 = dir;
7184 836734 dir = lookat;
7185
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7186 else
7187 {
7188 tiledir_big(dir,(anim == a4FRM4EYEB));
7189 tile+=2*f4;
7190 ignore_extend = true;
7191 }
7192 836734 dir = dir2;
7193 }
7194 836734 break;
7195
7196 case aFLIP:
7197 {
7198 1692048 flip = f2&1;
7199 }
7200 1692048 break;
7201
7202 case a2FRM:
7203 {
7204 1134909 tile += (1-f2);
7205 }
7206 1134909 break;
7207
7208 case a2FRMB:
7209 {
7210 tile+= 2*(1-f2);
7211 ignore_extend = true;
7212 }
7213 break;
7214
7215 case a2FRM4DIR:
7216 {
7217 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7218 }
7219 267131 break;
7220
7221 case a4FRM4DIRF:
7222 {
7223 4134380 basetile = n_frame_n_dir(4,4,f4);
7224
7225
2/2
✓ Branch 0 taken 2733532 times.
✓ Branch 1 taken 1400848 times.
4134380 if(clk2>0) //stopped to fire
7226 {
7227 1400848 tile+=20;
7228
7229
2/2
✓ Branch 0 taken 698186 times.
✓ Branch 1 taken 702662 times.
1400848 if(clk2<17) //firing
7230 {
7231 702662 tile+=20;
7232 702662 }
7233 1400848 }
7234 }
7235 4134380 break;
7236
7237 case a4FRM4DIR:
7238 {
7239 7515986 basetile = n_frame_n_dir(4,4,f4);
7240 }
7241 7515986 break;
7242
7243 case a4FRM8DIRF:
7244 {
7245 tilerows = 2;
7246 basetile = n_frame_n_dir(4,8,f4);
7247
7248 if(clk2>0) //stopped to fire
7249 {
7250 tile+=40;
7251
7252 if(clk2<17) //firing
7253 {
7254 tile+=40;
7255 }
7256 }
7257 }
7258 break;
7259
7260 case a4FRM8DIRB:
7261 case a4FRM8DIRFB:
7262 {
7263 3868 tilerows = 2;
7264 3868 tiledir_big(dir,false);
7265 3868 tile+=2*f4;
7266
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7267 {
7268 tile+=80;
7269
7270 if(clk2<17) //firing
7271 {
7272 tile+=80;
7273 }
7274 }
7275 3868 ignore_extend = true;
7276 }
7277 3868 break;
7278
7279 case a4FRM4DIRB:
7280 case a4FRM4DIRFB:
7281 {
7282 tilerows = 2;
7283 tiledir_big(dir,true);
7284 tile+=2*f4;
7285 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7286 {
7287 tile+=40;
7288
7289 if(clk2<17) //firing
7290 {
7291 tile+=40;
7292 }
7293 }
7294 ignore_extend = true;
7295 }
7296 break;
7297
7298 case aOCTO:
7299 {
7300
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165651 times.
✓ Branch 4 taken 157227 times.
582937 switch(dir)
7301 {
7302 case up:
7303 122459 flip = 2;
7304 122459 break;
7305
7306 case down:
7307 133448 flip = 0;
7308 133448 break;
7309
7310 case left:
7311 165651 flip = 0;
7312 165651 tile += 2;
7313 165651 break;
7314
7315 case right:
7316 157227 flip = 1;
7317 157227 tile += 2;
7318 157227 break;
7319 }
7320
7321 582937 tile+=f2;
7322 }
7323 582937 break;
7324
7325 case aWALK:
7326 {
7327
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7328 {
7329 case up:
7330 248704 tile+=3;
7331 248704 flip = f2;
7332 248704 break;
7333
7334 case down:
7335 267165 tile+=2;
7336 267165 flip = f2;
7337 267165 break;
7338
7339 case left:
7340 331694 flip=1;
7341 331694 tile += f2;
7342 331694 break;
7343
7344 case right:
7345 325802 flip=0;
7346 325802 tile += f2;
7347 325802 break;
7348 }
7349 }
7350 1178979 break;
7351
7352 case aDWALK:
7353 {
7354
3/4
✓ Branch 0 taken 92330 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92330 times.
✗ Branch 3 not taken.
880176 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7355 {
7356 tile=s_tile;
7357 basetile = s_tile;
7358 }
7359
7360
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260885 times.
✓ Branch 4 taken 255982 times.
880176 switch(dir)
7361 {
7362 case up:
7363 177728 tile+=2;
7364 177728 flip=f2;
7365 177728 break;
7366
7367 case down:
7368 185581 flip=0;
7369 185581 tile+=(1-f2);
7370 185581 break;
7371
7372 case left:
7373 260885 flip=1;
7374 260885 tile+=(3+f2);
7375 260885 break;
7376
7377 case right:
7378 255982 flip=0;
7379 255982 tile+=(3+f2);
7380 255982 break;
7381 }
7382 }
7383 880176 break;
7384
7385 case aTEK:
7386 {
7387
2/2
✓ Branch 0 taken 139976 times.
✓ Branch 1 taken 79120 times.
219096 if(misc==0)
7388 {
7389 79120 tile += f2;
7390 79120 }
7391
2/2
✓ Branch 0 taken 73149 times.
✓ Branch 1 taken 66827 times.
139976 else if(misc!=1)
7392 {
7393 66827 ++tile;
7394 66827 }
7395 }
7396 219096 break;
7397
7398 case aNEWTEK:
7399 {
7400
2/2
✓ Branch 0 taken 475246 times.
✓ Branch 1 taken 1343058 times.
1818304 if(step<0) //up
7401 {
7402
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 235369 times.
✓ Branch 2 taken 239877 times.
475246 switch(clk3)
7403 {
7404 case left:
7405 235369 flip=0;
7406 235369 tile+=20;
7407 235369 break;
7408
7409 case right:
7410 239877 flip=0;
7411 239877 tile+=24;
7412 239877 break;
7413 }
7414 475246 }
7415
2/2
✓ Branch 0 taken 54749 times.
✓ Branch 1 taken 1288309 times.
1343058 else if(step==0)
7416 {
7417
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 40566 times.
✓ Branch 2 taken 14183 times.
54749 switch(clk3)
7418 {
7419 case left:
7420 40566 flip=0;
7421 40566 tile+=8;
7422 40566 break;
7423
7424 case right:
7425 14183 flip=0;
7426 14183 tile+=12;
7427 14183 break;
7428 }
7429 54749 } //down
7430 else
7431 {
7432
3/3
✓ Branch 0 taken 109149 times.
✓ Branch 1 taken 593340 times.
✓ Branch 2 taken 585820 times.
1288309 switch(clk3)
7433 {
7434 case left:
7435 593340 flip=0;
7436 593340 tile+=28;
7437 593340 break;
7438
7439 case right:
7440 585820 flip=0;
7441 585820 tile+=32;
7442 585820 break;
7443 }
7444 }
7445
7446
2/2
✓ Branch 0 taken 1238755 times.
✓ Branch 1 taken 579549 times.
1818304 if(misc==0)
7447 {
7448 579549 tile+=f4;
7449 579549 }
7450
2/2
✓ Branch 0 taken 582085 times.
✓ Branch 1 taken 656670 times.
1238755 else if(misc!=1)
7451 {
7452 656670 tile+=2;
7453 656670 }
7454 }
7455 1818304 break;
7456
7457 case aARMOS:
7458 {
7459
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7460 {
7461 5401 tile += fx;
7462
7463
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7464 1197 tile += 2;
7465 5401 }
7466 }
7467 8628 break;
7468
7469 case aARMOS4:
7470 {
7471
5/5
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 29165 times.
✓ Branch 2 taken 92624 times.
✓ Branch 3 taken 43654 times.
✓ Branch 4 taken 43190 times.
209083 switch(dir)
7472 {
7473 case up:
7474 29165 flip=0;
7475 29165 break;
7476
7477 case down:
7478 92624 flip=0;
7479 92624 tile+=4;
7480 92624 break;
7481
7482 case left:
7483 43654 flip=0;
7484 43654 tile+=8;
7485 43654 break;
7486
7487 case right:
7488 43190 flip=0;
7489 43190 tile+=12;
7490 43190 break;
7491 }
7492
7493
2/2
✓ Branch 0 taken 63155 times.
✓ Branch 1 taken 145928 times.
209083 if(!fading)
7494 {
7495 145928 tile+=f4;
7496 145928 }
7497 }
7498 209083 break;
7499
7500 case aGHINI:
7501 {
7502
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7503 {
7504 case 8:
7505 case 9:
7506 case up:
7507 28037 ++tile;
7508 28037 flip=0;
7509 28037 break;
7510
7511 case 15:
7512 452 ++tile;
7513 452 flip=1;
7514 452 break;
7515
7516 case 10:
7517 case 11:
7518 case right:
7519 32092 flip=1;
7520 32092 break;
7521
7522 default:
7523 72763 flip=0;
7524 72763 break;
7525 }
7526 }
7527 133344 break;
7528
7529 case a2FRMPOS:
7530 {
7531 1755010 tile+=posframe;
7532 }
7533 1755010 break;
7534
7535 case a4FRMPOS4DIR:
7536 {
7537 363745 basetile = n_frame_n_dir(4,4,0);
7538 // tile+=f2;
7539 363745 tile+=posframe;
7540 }
7541 363745 break;
7542
7543 case a4FRMPOS4DIRF:
7544 {
7545 1433 basetile = n_frame_n_dir(4,4,0);
7546
7547
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7548 {
7549 197 tile+=20;
7550
7551
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7552 {
7553 64 tile+=20;
7554 64 }
7555 197 }
7556
7557 // tile+=f2;
7558 1433 tile+=posframe;
7559 }
7560 1433 break;
7561
7562 case a4FRMPOS8DIR:
7563 {
7564 7018408 tilerows = 2;
7565 7018408 int32_t n = tile;
7566 7018408 basetile = n_frame_n_dir(4,8,0);
7567 // tile+=f2;
7568 7018408 tile+=posframe;
7569 }
7570 7018408 break;
7571
7572 case a4FRMPOS8DIRF:
7573 {
7574 tilerows = 2;
7575 basetile = n_frame_n_dir(4,8,0);
7576
7577 if(clk2>0) //stopped to fire
7578 {
7579 tile+=40;
7580
7581 if(clk2<17) //firing
7582 {
7583 tile+=40;
7584 }
7585 }
7586
7587 tile+=posframe;
7588 }
7589 break;
7590
7591 case aNEWLEV:
7592 {
7593 747030 tiledir(dir,true);
7594
7595
4/5
✓ Branch 0 taken 258994 times.
✓ Branch 1 taken 115368 times.
✓ Branch 2 taken 48980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 323688 times.
747030 switch(misc)
7596 {
7597 case -1:
7598 case 0:
7599 258994 return;
7600
7601 case 1:
7602
7603 // case 5: cs = d->misc2; break;
7604 case 5:
7605 115368 cs = dmisc2;
7606 115368 break;
7607
7608 case 2:
7609 case 4:
7610 48980 tile += 20;
7611 48980 break;
7612
7613 case 3:
7614 323688 tile += 40;
7615 323688 break;
7616 }
7617
7618 488036 tile+=f4;
7619 }
7620 488036 break;
7621
7622 case aLEV:
7623 {
7624 276997 f4 = ((clk/5)&1);
7625
7626
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7627 {
7628 case -1:
7629 case 0:
7630 127945 return;
7631
7632 case 1:
7633
7634 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7635 case 5:
7636 33336 tile += (f2) ? 1 : 0;
7637 33336 cs = dmisc2;
7638 33336 break;
7639
7640 case 2:
7641 case 4:
7642 14658 tile += 2;
7643 14658 break;
7644
7645 case 3:
7646 101058 tile += (f4) ? 4 : 3;
7647 101058 break;
7648 }
7649 }
7650 149052 break;
7651
7652 case aWALLM:
7653 {
7654
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7655 {
7656 139764 tile += f2;
7657 139764 }
7658 }
7659 140514 break;
7660
7661 case aNEWWALLM:
7662 {
7663 366633 int32_t tempdir=0;
7664
7665
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7666 {
7667 case 1:
7668 case 2:
7669 43340 tempdir=clk3;
7670 43340 break;
7671
7672 case 3:
7673 case 4:
7674 case 5:
7675 38855 tempdir=dir;
7676 38855 break;
7677
7678 case 6:
7679 case 7:
7680 8438 tempdir=clk3^1;
7681 8438 break;
7682 }
7683
7684 366633 tiledir(tempdir,true);
7685
7686
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7687 {
7688 364725 tile+=f4;
7689 364725 }
7690 }
7691 366633 break;
7692
7693 case a4FRMNODIR:
7694 {
7695 171508 tile+=f4;
7696 }
7697 171508 break;
7698
7699 } // switch(d->anim)
7700
7701 // flashing
7702 // if(d->flags & guy_flashing)
7703
2/2
✓ Branch 0 taken 38998166 times.
✓ Branch 1 taken 747549 times.
39745715 if(flags & guy_flashing)
7704 {
7705 747549 cs = (frame&3) + 6;
7706 747549 }
7707
7708
2/2
✓ Branch 0 taken 39334767 times.
✓ Branch 1 taken 410948 times.
39745715 if(flags&guy_transparent)
7709 {
7710 410948 drawstyle=1;
7711 410948 }
7712
7713 39745715 int32_t change = tile-basetile;
7714
7715
3/6
✓ Branch 0 taken 2030319 times.
✓ Branch 1 taken 37715396 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2030319 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
39745715 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7716 {
7717
2/2
✓ Branch 0 taken 1768291 times.
✓ Branch 1 taken 262028 times.
2030319 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7718 {
7719 1768291 tile=basetile+txsz*change;
7720 1768291 }
7721 else
7722 {
7723 262028 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7724 }
7725 2030319 }
7726 else
7727 {
7728 37715396 tile=basetile+change;
7729 }
7730 40135036 }
7731
7732 81114 int32_t enemy::wpnsfx(int32_t wpn)
7733 {
7734
3/3
✓ Branch 0 taken 22419 times.
✓ Branch 1 taken 40988 times.
✓ Branch 2 taken 17707 times.
81114 switch (wpn)
7735 {
7736 case wScript1:
7737 case wScript2:
7738 case wScript3:
7739 case wScript4:
7740 case wScript5:
7741 case wScript6:
7742 case wScript7:
7743 case wScript8:
7744 case wScript9:
7745 case wScript10: //sure why not
7746 case ewFireTrail:
7747 case ewFlame:
7748 case ewFlame2Trail:
7749 case ewFlame2:
7750 case ewWind:
7751 case ewMagic:
7752 case ewIce:
7753 22419 return firesfx;
7754
7755 case ewRock:
7756 case ewFireball2:
7757 case ewFireball:
7758
2/2
✓ Branch 0 taken 5530 times.
✓ Branch 1 taken 35458 times.
40988 if (get_qr(qr_MORESOUNDS)) return firesfx;
7759 35458 break;
7760 }
7761
7762 53165 return 0;
7763 81114 }
7764
7765 76989520 int32_t enemy::run_script(int32_t mode)
7766 {
7767
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 76989264 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
76989520 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7768
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76989264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76989264 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7769 76989264 return RUNSCRIPT_OK;
7770 auto scrty = *get_scrtype();
7771 auto uid = getUID();
7772 if(!FFCore.doscript(scrty,uid))
7773 return RUNSCRIPT_OK;
7774 int32_t ret = RUNSCRIPT_OK;
7775 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7776 switch(mode)
7777 {
7778 case MODE_NORMAL:
7779 return ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7780 case MODE_WAITDRAW:
7781 if(waitdraw)
7782 {
7783 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7784 waitdraw = false;
7785 }
7786 break;
7787 }
7788 return ret;
7789 76989520 }
7790 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7791 {
7792 return al_map_rgba(255,0,0,opacity);
7793 }
7794
7795 // good guys, fires, fairy, and other non-enemies
7796 // based on enemy class b/c guys in dungeons act sort of like enemies
7797 // also easier to manage all the guys this way
7798 2191 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7799 2191 {
7800 2191 mainguy=mg;
7801 2191 canfreeze=false;
7802 2191 dir=down;
7803
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2191 times.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
2191 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7804 2191 hxofs=2;
7805 2191 hzsz=8;
7806 2191 hit_width=12;
7807 2191 hit_height=17;
7808
7809
10/12
✓ Branch 0 taken 2191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 1426 times.
✓ Branch 6 taken 743 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 276 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 260 times.
2191 if(!superman && (!isdungeon(screen_spawned) || id==gFAIRY || id==gFIRE || id==gZELDA))
7810 {
7811 1931 superman = 1;
7812 1931 hxofs=1000;
7813 1931 }
7814 2191 }
7815
7816 943762 bool guy::animate(int32_t index)
7817 {
7818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 943762 times.
943762 if(switch_hooked) return enemy::animate(index);
7819
6/6
✓ Branch 0 taken 543192 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 8298 times.
✓ Branch 3 taken 534894 times.
✓ Branch 4 taken 7092 times.
✓ Branch 5 taken 1206 times.
943762 if(mainguy && clk==0 && misc==0)
7820 {
7821 1206 setupscreen();
7822 1206 misc = 1;
7823 1206 }
7824
7825
4/4
✓ Branch 0 taken 543192 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 542862 times.
✓ Branch 3 taken 330 times.
943762 if(mainguy && fadeclk==0)
7826 330 return true;
7827
7828 943432 hp=256; // good guys never die...
7829
7830
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 942510 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
943432 if(hclk && !clk2)
7831 {
7832 // but if they get hit...
7833 16 ++clk2; // only do this once
7834
7835
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7836 {
7837 7 addenemy(screen_spawned,BSZ?64:72,68,eSHOOTFBALL,0);
7838 7 addenemy(screen_spawned,BSZ?176:168,68,eSHOOTFBALL,0);
7839 7 }
7840 16 }
7841
7842 943432 return enemy::animate(index);
7843 943762 }
7844
7845 947535 void guy::draw(BITMAP *dest)
7846 {
7847 947535 update_enemy_frame();
7848
7849
6/6
✓ Branch 0 taken 546756 times.
✓ Branch 1 taken 400779 times.
✓ Branch 2 taken 22911 times.
✓ Branch 3 taken 523845 times.
✓ Branch 4 taken 11064 times.
✓ Branch 5 taken 11847 times.
947535 if(!mainguy || fadeclk<0 || fadeclk&1)
7850 935688 enemy::draw(dest);
7851 947535 }
7852
7853 760 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7854 760 {
7855 760 clk4=0;
7856
4/8
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 760 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 760 times.
✗ Branch 7 not taken.
760 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7857 // Spawn type
7858
2/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 if(flags & guy_fade_flicker)
7859 {
7860 clk=0;
7861 superman = 1;
7862 fading=fade_flicker;
7863 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7864 dir=down;
7865
7866 if(!canmove(down,(zfix)8,spw_none,false))
7867 clk3=int32_t(13.0/step);
7868 }
7869
3/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 676 times.
✓ Branch 3 taken 84 times.
760 else if(flags & guy_fade_instant)
7870 {
7871 84 clk=0;
7872 84 }
7873
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
760 if (SIZEflags != 0) init_size_flags();;
7874 760 }
7875
7876 167472 bool eFire::animate(int32_t index)
7877 {
7878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167472 times.
167472 if(switch_hooked) return enemy::animate(index);
7879
2/4
✓ Branch 0 taken 167472 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167472 times.
167472 if(fallclk||drownclk) return enemy::animate(index);
7880
2/2
✓ Branch 0 taken 165756 times.
✓ Branch 1 taken 1716 times.
167472 if(fading)
7881 {
7882
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
1716 if(++clk4 > 60)
7883 {
7884 1 clk4=0;
7885 1 superman=0;
7886 1 fading=0;
7887
7888
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags&guy_armos && z==0 && fakez==0)
7889 removearmos(x,y,ffcactivated);
7890
7891 1 clk2=0;
7892
7893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7894 {
7895 1 dir=0;
7896 1 y = TRUNCATE_TILE(y.getInt());
7897 1 }
7898
7899 1 return Dead(index);
7900 }
7901
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1715 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7902 removearmos(x,y,ffcactivated);
7903 1715 }
7904
7905 167471 return enemy::animate(index);
7906 167472 }
7907
7908 351659 void eFire::draw(BITMAP *dest)
7909 {
7910 351659 update_enemy_frame();
7911 351659 enemy::draw(dest);
7912 351659 }
7913
7914 415 int32_t eFire::takehit(weapon *w, weapon* realweap)
7915 {
7916 415 int32_t wpnId = w->id;
7917 415 int32_t wpnDir = w->dir;
7918
7919
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7920 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7921 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7922 {
7923 shield = false;
7924 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7925
7926 if(get_qr(qr_BRKNSHLDTILES))
7927 o_tile=s_tile;
7928 }
7929
7930 415 int32_t ret = enemy::takehit(w,realweap);
7931 415 return ret;
7932 }
7933
7934 void eFire::break_shield()
7935 {
7936 if(!shield)
7937 return;
7938
7939 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7940 shield=false;
7941
7942 if(get_qr(qr_BRKNSHLDTILES))
7943 o_tile=s_tile;
7944 }
7945
7946 void eFire::repair_shield()
7947 {
7948 if (shield)
7949 return;
7950
7951 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
7952 return;
7953
7954 shield = true;
7955
7956 if (get_qr(qr_BRKNSHLDTILES))
7957 {
7958 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
7959 else o_tile = d->tile;
7960 }
7961 }
7962
7963 7627 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7964 7627 {
7965 7627 clk4=0;
7966
4/8
✓ Branch 0 taken 7627 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7627 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7627 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7627 times.
✗ Branch 7 not taken.
7627 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7967
7968 // Spawn type
7969
2/4
✓ Branch 0 taken 7627 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7627 times.
7627 if(flags & guy_fade_flicker)
7970 {
7971 clk=0;
7972 superman = 1;
7973 fading=fade_flicker;
7974 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7975 dir=down;
7976
7977 if(!canmove(down,(zfix)8,spw_none,false))
7978 clk3=int32_t(13.0/step);
7979 }
7980
3/4
✓ Branch 0 taken 7627 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6443 times.
✓ Branch 3 taken 1184 times.
7627 else if(flags & guy_fade_instant)
7981 {
7982 1184 clk=0;
7983 1184 }
7984
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7620 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7627 if (SIZEflags != 0) init_size_flags();;
7985 7627 }
7986
7987 1957407 bool eOther::animate(int32_t index)
7988 {
7989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1957407 times.
1957407 if(switch_hooked) return enemy::animate(index);
7990
3/4
✓ Branch 0 taken 1955821 times.
✓ Branch 1 taken 1586 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1955821 times.
1957407 if(fallclk||drownclk) return enemy::animate(index);
7991
2/2
✓ Branch 0 taken 1947407 times.
✓ Branch 1 taken 8414 times.
1955821 if(fading)
7992 {
7993
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 8387 times.
8414 if(++clk4 > 60)
7994 {
7995 27 clk4=0;
7996 27 superman=0;
7997 27 fading=0;
7998
7999
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27 if(flags&guy_armos && z==0 && fakez==0)
8000 removearmos(x,y,ffcactivated);
8001
8002 27 clk2=0;
8003
8004
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 2 times.
27 if(!canmove(down,(zfix)8,spw_none,false))
8005 {
8006 2 dir=0;
8007 2 y = TRUNCATE_TILE(y.getInt());
8008 2 }
8009
8010 27 return Dead(index);
8011 }
8012
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8387 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8013 removearmos(x,y,ffcactivated);
8014 8387 }
8015
8016 1955794 return enemy::animate(index);
8017 1957407 }
8018
8019 2063010 void eOther::draw(BITMAP *dest)
8020 {
8021 2063010 update_enemy_frame();
8022 2063010 enemy::draw(dest);
8023 2063010 }
8024
8025 14585 int32_t eOther::takehit(weapon *w, weapon* realweap)
8026 {
8027 14585 int32_t wpnId = w->id;
8028 14585 int32_t wpnDir = w->dir;
8029
8030
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14543 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
14585 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8031 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8032 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8033 {
8034 shield = false;
8035 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8036
8037 if(get_qr(qr_BRKNSHLDTILES))
8038 o_tile=s_tile;
8039 }
8040
8041 14585 int32_t ret = enemy::takehit(w,realweap);
8042 14585 return ret;
8043 }
8044
8045 void eOther::break_shield()
8046 {
8047 if(!shield)
8048 return;
8049
8050 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8051 shield=false;
8052
8053 if(get_qr(qr_BRKNSHLDTILES))
8054 o_tile=s_tile;
8055 }
8056
8057 void eOther::repair_shield()
8058 {
8059 if (shield)
8060 return;
8061
8062 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8063 return;
8064
8065 shield = true;
8066
8067 if (get_qr(qr_BRKNSHLDTILES))
8068 {
8069 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8070 else o_tile = d->tile;
8071 }
8072 }
8073
8074 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8075 {
8076 clk4=0;
8077 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8078
8079 // Spawn type
8080 if(flags & guy_fade_flicker)
8081 {
8082 clk=0;
8083 superman = 1;
8084 fading=fade_flicker;
8085 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8086 dir=down;
8087
8088 if(!canmove(down,(zfix)8,spw_none,false))
8089 clk3=int32_t(13.0/step);
8090 }
8091 else if(flags & guy_fade_instant)
8092 {
8093 clk=0;
8094 }
8095 if (SIZEflags != 0) init_size_flags();;
8096 }
8097
8098 bool eScript::animate(int32_t index)
8099 {
8100 if(switch_hooked) return enemy::animate(index);
8101 if(fallclk||drownclk) return enemy::animate(index);
8102 if(fading)
8103 {
8104 if(++clk4 > 60)
8105 {
8106 clk4=0;
8107 superman=0;
8108 fading=0;
8109
8110 if(flags&guy_armos && z==0 && fakez==0)
8111 removearmos(x,y,ffcactivated);
8112
8113 clk2=0;
8114
8115 if(!canmove(down,(zfix)8,spw_none,false))
8116 {
8117 dir=0;
8118 y = TRUNCATE_TILE(y.getInt());
8119 }
8120
8121 return Dead(index);
8122 }
8123 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8124 removearmos(x,y,ffcactivated);
8125 }
8126
8127 return enemy::animate(index);
8128 }
8129
8130 void eScript::draw(BITMAP *dest)
8131 {
8132 update_enemy_frame();
8133 enemy::draw(dest);
8134 }
8135
8136 int32_t eScript::takehit(weapon *w, weapon* realweap)
8137 {
8138 int32_t wpnId = w->id;
8139 int32_t wpnDir = w->dir;
8140
8141 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8142 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8143 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8144 {
8145 shield = false;
8146 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8147
8148 if(get_qr(qr_BRKNSHLDTILES))
8149 o_tile=s_tile;
8150 }
8151
8152 int32_t ret = enemy::takehit(w,realweap);
8153 return ret;
8154 }
8155
8156 void eScript::break_shield()
8157 {
8158 if(!shield)
8159 return;
8160
8161 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8162 shield=false;
8163
8164 if(get_qr(qr_BRKNSHLDTILES))
8165 o_tile=s_tile;
8166 }
8167
8168 void eScript::repair_shield()
8169 {
8170 if (shield)
8171 return;
8172
8173 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8174 return;
8175
8176 shield = true;
8177
8178 if (get_qr(qr_BRKNSHLDTILES))
8179 {
8180 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8181 else o_tile = d->tile;
8182 }
8183 }
8184
8185
8186 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8187 {
8188 clk4=0;
8189 hyofs = -32768; //No hitbox initially.
8190 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8191
8192 // Spawn type
8193 if(flags & guy_fade_flicker)
8194 {
8195 clk=0;
8196 superman = 1;
8197 fading=fade_flicker;
8198 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8199 dir=down;
8200
8201 if(!canmove(down,(zfix)8,spw_none,false))
8202 clk3=int32_t(13.0/step);
8203 }
8204 else if(flags & guy_fade_instant)
8205 {
8206 clk=0;
8207 }
8208 if (SIZEflags != 0) init_size_flags();;
8209 }
8210
8211 bool eFriendly::animate(int32_t index)
8212 {
8213 if(switch_hooked) return enemy::animate(index);
8214 if(fallclk||drownclk) return enemy::animate(index);
8215 if(fading)
8216 {
8217 if(++clk4 > 60)
8218 {
8219 clk4=0;
8220 superman=0;
8221 fading=0;
8222
8223 if(flags&guy_armos && z==0 && fakez==0)
8224 removearmos(x,y,ffcactivated);
8225
8226 clk2=0;
8227
8228 if(!canmove(down,(zfix)8,spw_none,false))
8229 {
8230 dir=0;
8231 y = TRUNCATE_TILE(y.getInt());
8232 }
8233
8234 return Dead(index);
8235 }
8236 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8237 removearmos(x,y,ffcactivated);
8238 }
8239
8240 return enemy::animate(index);
8241 }
8242
8243 void eFriendly::draw(BITMAP *dest)
8244 {
8245 update_enemy_frame();
8246 enemy::draw(dest);
8247 }
8248
8249 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8250 {
8251 int32_t wpnId = w->id;
8252 int32_t wpnDir = w->dir;
8253
8254 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8255 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8256 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8257 {
8258 shield = false;
8259 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8260
8261 if(get_qr(qr_BRKNSHLDTILES))
8262 o_tile=s_tile;
8263 }
8264
8265 int32_t ret = enemy::takehit(w,realweap);
8266 return ret;
8267 }
8268
8269 void eFriendly::break_shield()
8270 {
8271 if(!shield)
8272 return;
8273
8274 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8275 shield=false;
8276
8277 if(get_qr(qr_BRKNSHLDTILES))
8278 o_tile=s_tile;
8279 }
8280
8281 void eFriendly::repair_shield()
8282 {
8283 if (shield)
8284 return;
8285
8286 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8287 return;
8288
8289 shield = true;
8290
8291 if (get_qr(qr_BRKNSHLDTILES))
8292 {
8293 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8294 else o_tile = d->tile;
8295 }
8296 }
8297
8298
8299 780032 void enemy::removearmos(int32_t ax,int32_t ay, std::optional<ffc_handle_t> ffcactive)
8300 {
8301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780032 times.
780032 if (ffcactive)
8302 {
8303 removearmosffc(*ffcactive);
8304 return;
8305 }
8306
2/2
✓ Branch 0 taken 779016 times.
✓ Branch 1 taken 1016 times.
780032 if(did_armos)
8307 {
8308 779016 return;
8309 }
8310
8311 1016 auto rpos_handle = get_rpos_handle_for_world_xy(ax, ay, 0);
8312 1016 mapscr* scr = rpos_handle.scr;
8313 1016 ax = TRUNCATE_TILE(ax);
8314 1016 ay = TRUNCATE_TILE(ay);
8315
8316 1016 did_armos=true;
8317 1016 int32_t cd = rpos_handle.pos;
8318 1016 int32_t f = rpos_handle.sflag();
8319 1016 int32_t f2 = rpos_handle.cflag();
8320
8321
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 176 times.
1016 if (rpos_handle.ctype() != cARMOS)
8322 {
8323 840 return;
8324 }
8325
8326 176 scr->data[cd] = scr->undercombo;
8327 176 scr->cset[cd] = scr->undercset;
8328 176 scr->sflag[cd] = 0;
8329
8330
3/4
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154 times.
176 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8331 {
8332 22 scr->data[cd] = scr->secretcombo[sSTAIRS];
8333 22 scr->cset[cd] = scr->secretcset[sSTAIRS];
8334 22 scr->sflag[cd]=scr->secretflag[sSTAIRS];
8335 22 sfx(scr->secretsfx);
8336 22 }
8337
8338
3/4
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 173 times.
176 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8339 {
8340
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8341 {
8342 3 additem(ax,ay,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8343 3 sfx(scr->secretsfx);
8344 3 }
8345 3 }
8346
8347 176 putcombo(scrollbuf,ax,ay,scr->data[cd],scr->cset[cd]);
8348 780032 }
8349
8350 void enemy::removearmosffc(const ffc_handle_t& ffc_handle)
8351 {
8352 if(did_armos)
8353 {
8354 return;
8355 }
8356
8357 did_armos=true;
8358 ffcdata& ffc = *ffc_handle.ffc;
8359 mapscr* scr = ffc_handle.scr;
8360 auto& cmb = ffc_handle.combo();
8361 int32_t f2 = cmb.flag;
8362
8363 if(cmb.type!=cARMOS)
8364 {
8365 return;
8366 }
8367
8368 ffc_handle.set_data(scr->undercombo);
8369 ffc_handle.set_cset(scr->undercset);
8370
8371 if(f2 == mfARMOS_SECRET)
8372 {
8373 ffc_handle.set_data(scr->secretcombo[sSTAIRS]);
8374 ffc_handle.set_cset(scr->secretcset[sSTAIRS]);
8375 sfx(scr->secretsfx);
8376 }
8377
8378 if(f2 == mfARMOS_ITEM)
8379 {
8380 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8381 {
8382 additem(ffc.x,ffc.y,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8383 sfx(scr->secretsfx);
8384 }
8385 }
8386
8387 putcombo(scrollbuf,ffc.x,ffc.y,ffc_handle.data(),ffc.cset);
8388 }
8389
8390
8391 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8392 461 {
8393 461 fading=fade_flicker;
8394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8395 461 dir=12;
8396 461 movestatus=1;
8397
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8398 461 clk=0;
8399 461 clk4=0;
8400
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if (SIZEflags != 0) init_size_flags();;
8401 461 }
8402
8403 117025 bool eGhini::animate(int32_t index)
8404 {
8405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8406
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8407
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8408 50 return Dead(index);
8409
8410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8411 {
8412
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8413 {
8414
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8415 54853 misc=2;
8416
8417
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8418 89752 removearmos(x,y,ffcactivated);
8419 89752 }
8420
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8421 {
8422 425 misc=1;
8423 425 clk3=32;
8424 425 fading=0;
8425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if (ffcactivated)
8426 {
8427 activation_counters_ffc[ffcactivated->id] = 0;
8428 removearmosffc(*ffcactivated);
8429 }
8430 else
8431 {
8432 425 rpos_t rpos = COMBOPOS_REGION_B(x, y);
8433
1/2
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
425 if (rpos != rpos_t::None)
8434 {
8435 425 activation_counters[(int)rpos] = 0;
8436 425 removearmos(x,y);
8437 425 }
8438 }
8439 425 }
8440 116975 }
8441
8442 116975 clk4++;
8443
8444 116975 return enemy::animate(index);
8445 117025 }
8446
8447 238808 void eGhini::draw(BITMAP *dest)
8448 {
8449 238808 update_enemy_frame();
8450 238808 enemy::draw(dest);
8451 238808 }
8452
8453 2 void eGhini::kickbucket()
8454 {
8455 2 hp=-1000; // don't call death_sfx()
8456 2 }
8457
8458
2/4
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5212 times.
✗ Branch 3 not taken.
10424 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8459 5212 {
8460
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 old_y=y;
8461 5212 dir=down;
8462 5212 misc=1;
8463 5212 clk=-15;
8464
8465
2/2
✓ Branch 0 taken 2649 times.
✓ Branch 1 taken 2563 times.
5212 if(!BSZ)
8466
1/2
✓ Branch 0 taken 2649 times.
✗ Branch 1 not taken.
2649 clk*=zc_oldrand()%3+1;
8467
8468 // avoid divide by 0 errors
8469
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 if(dmisc1 == 0)
8470 dmisc1 = 24;
8471
8472
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 if(dmisc2 == 0)
8473 dmisc2 = 3;
8474
8475 //nets+760;
8476
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5212 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5212 if (SIZEflags != 0) init_size_flags();;
8477 5212 }
8478
8479 1436518 bool eTektite::animate(int32_t index)
8480 {
8481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1436518 times.
1436518 if(switch_hooked) return enemy::animate(index);
8482
4/4
✓ Branch 0 taken 1427644 times.
✓ Branch 1 taken 8874 times.
✓ Branch 2 taken 8874 times.
✓ Branch 3 taken 1425214 times.
1436518 if(fallclk||drownclk) return enemy::animate(index);
8483
2/2
✓ Branch 0 taken 26667 times.
✓ Branch 1 taken 1398547 times.
1425214 if(dying)
8484 26667 return Dead(index);
8485
8486
2/2
✓ Branch 0 taken 1361444 times.
✓ Branch 1 taken 37103 times.
1398547 if(clk==0)
8487 {
8488 37103 removearmos(x,y,ffcactivated);
8489 37103 }
8490
8491
2/2
✓ Branch 0 taken 1057364 times.
✓ Branch 1 taken 341183 times.
1398547 if(get_qr(qr_ENEMIESZAXIS))
8492 {
8493 341183 y=floor_y;
8494 341183 }
8495
8496
9/10
✓ Branch 0 taken 1283739 times.
✓ Branch 1 taken 114808 times.
✓ Branch 2 taken 1270175 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1270175 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1258999 times.
✓ Branch 8 taken 11988 times.
✓ Branch 9 taken 21878 times.
1398547 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8497 {
8498
4/4
✓ Branch 0 taken 20260 times.
✓ Branch 1 taken 421702 times.
✓ Branch 2 taken 345150 times.
✓ Branch 3 taken 493765 times.
1280877 switch(misc)
8499 {
8500 case 0: // normal
8501
2/2
✓ Branch 0 taken 410469 times.
✓ Branch 1 taken 11233 times.
421702 if(!(zc_oldrand()%dmisc1))
8502 {
8503 11233 misc=1;
8504 11233 clk2=32;
8505 11233 }
8506
8507 421702 break;
8508
8509 case 1: // waiting to pounce
8510
2/2
✓ Branch 0 taken 324515 times.
✓ Branch 1 taken 20635 times.
345150 if(--clk2<=0)
8511 {
8512 20635 int32_t r=zc_oldrand();
8513 20635 misc=2;
8514 20635 step=0-(zslongToFix(dstep*100)); // initial speed
8515 20635 clk3=(r&1)+2; // left or right
8516 20635 clk2start=clk2=(r&31)+10; // flight time
8517
8518
2/2
✓ Branch 0 taken 18212 times.
✓ Branch 1 taken 2423 times.
20635 if(y<32) clk2+=2; // make them come down from top of screen
8519
8520
2/2
✓ Branch 0 taken 15717 times.
✓ Branch 1 taken 4918 times.
20635 if(y>world_h-64) clk2-=2; // make them go back up
8521
8522 20635 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8523 20635 }
8524
8525 345150 break;
8526
8527 case 2: // in flight
8528 493765 move(step);
8529
8530
2/2
✓ Branch 0 taken 234357 times.
✓ Branch 1 taken 259408 times.
493765 if(step>0) //going down
8531 {
8532
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 233725 times.
234357 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8533 {
8534 632 step=0-step;
8535 632 }
8536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233725 times.
233725 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8537 {
8538 step=0-step;
8539 }
8540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233725 times.
233725 else if(ispitfall(x+8,y+16))
8541 {
8542 step=0-step;
8543 }
8544
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 233678 times.
233725 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8545 {
8546 47 step=0-step;
8547 47 }
8548
2/2
✓ Branch 0 taken 233667 times.
✓ Branch 1 taken 11 times.
233678 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8549 {
8550 11 step=0-step;
8551 11 }
8552 234357 }
8553
2/2
✓ Branch 0 taken 15166 times.
✓ Branch 1 taken 244242 times.
259408 else if(step<0)
8554 {
8555
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 243804 times.
244242 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8556 {
8557 438 step=0-step;
8558 438 }
8559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243804 times.
243804 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8560 {
8561 step=0-step;
8562 }
8563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243804 times.
243804 else if(ispitfall(x+8,y))
8564 {
8565 step=0-step;
8566 }
8567
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 243783 times.
243804 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8568 {
8569 21 step=0-step;
8570 21 }
8571
2/2
✓ Branch 0 taken 243764 times.
✓ Branch 1 taken 19 times.
243783 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8572 {
8573 19 step=0-step;
8574 19 }
8575 244242 }
8576
8577
2/2
✓ Branch 0 taken 244331 times.
✓ Branch 1 taken 249434 times.
493765 if(clk3==left)
8578 {
8579
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 244056 times.
244331 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8580 {
8581 275 clk3^=1;
8582 275 }
8583
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 244050 times.
244056 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8584 {
8585 6 clk3^=1;
8586 6 }
8587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244050 times.
244050 else if(ispitfall(x,y+8))
8588 {
8589 clk3^=1;
8590 }
8591
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 244020 times.
244050 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8592 {
8593 30 clk3^=1;
8594 30 }
8595
2/2
✓ Branch 0 taken 244008 times.
✓ Branch 1 taken 12 times.
244020 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8596 {
8597 12 clk3^=1;
8598 12 }
8599 244331 }
8600 else
8601 {
8602
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 249158 times.
249434 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8603 {
8604 276 clk3^=1;
8605 276 }
8606
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 249146 times.
249158 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8607 {
8608 12 clk3^=1;
8609 12 }
8610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249146 times.
249146 else if(ispitfall(x+16,y+8))
8611 {
8612 clk3^=1;
8613 }
8614
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 249141 times.
249146 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8615 {
8616 5 clk3^=1;
8617 5 }
8618
2/2
✓ Branch 0 taken 249129 times.
✓ Branch 1 taken 12 times.
249141 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8619 {
8620 12 clk3^=1;
8621 12 }
8622 }
8623
8624 493765 --c;
8625
8626
4/4
✓ Branch 0 taken 151531 times.
✓ Branch 1 taken 342234 times.
✓ Branch 2 taken 320688 times.
✓ Branch 3 taken 173077 times.
493765 if(c<0 && step<zslongToFix(dstep*100))
8627 {
8628 173077 step+=zslongToFix(dmisc3*100);
8629 173077 }
8630
8631 493765 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8632
8633
2/2
✓ Branch 0 taken 493043 times.
✓ Branch 1 taken 722 times.
493765 if(x<=16-nb) clk3=right;
8634
8635
2/2
✓ Branch 0 taken 492773 times.
✓ Branch 1 taken 992 times.
493765 if(x>=world_w-32+nb) clk3=left;
8636
8637 493765 x += (clk3==left) ? -1 : 1;
8638
8639
4/4
✓ Branch 0 taken 29039 times.
✓ Branch 1 taken 464726 times.
✓ Branch 2 taken 10130 times.
✓ Branch 3 taken 454596 times.
493765 if((--clk2<=0 && y>=16-nb) || y>=world_h-32+nb)
8640 {
8641
4/4
✓ Branch 0 taken 1621 times.
✓ Branch 1 taken 17288 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 185 times.
39169 if(y>=world_h-32+nb && get_qr(qr_ENEMIESZAXIS))
8642 {
8643 185 step=0-step;
8644 185 y--;
8645 185 }
8646
2/2
✓ Branch 0 taken 5796 times.
✓ Branch 1 taken 12928 times.
18724 else if(zc_oldrand()%dmisc2) //land and wait
8647 {
8648 12928 clk=misc=0;
8649 12928 } //land and jump again
8650 else
8651 {
8652 5796 misc=1;
8653 5796 clk2=0;
8654 }
8655 18909 }
8656
8657 473505 break;
8658 } // switch
8659 1260617 }
8660
8661
4/4
✓ Branch 0 taken 341183 times.
✓ Branch 1 taken 1059794 times.
✓ Branch 2 taken 231206 times.
✓ Branch 3 taken 109977 times.
1400977 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8662 {
8663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109977 times.
109977 if (moveflags & move_use_fake_z)
8664 {
8665 int32_t tempy = floor_y;
8666 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8667 floor_y = y;
8668 y=tempy-fakez;
8669 old_y = y;
8670 }
8671 else
8672 {
8673 109977 int32_t tempy = floor_y;
8674
6/6
✓ Branch 0 taken 55216 times.
✓ Branch 1 taken 54761 times.
✓ Branch 2 taken 104073 times.
✓ Branch 3 taken 5904 times.
✓ Branch 4 taken 50747 times.
✓ Branch 5 taken 53326 times.
109977 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8675 109977 floor_y = y;
8676 109977 y=tempy-z;
8677 109977 old_y = y;
8678 }
8679 109977 }
8680
8681
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1387413 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1400977 if(stunclk && (clk&31)==1)
8682 10637 clk=0;
8683
8684 1400977 return enemy::animate(index);
8685 1427644 }
8686
8687 809450 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8688 {
8689
5/6
✓ Branch 0 taken 632172 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 632172 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 606981 times.
✓ Branch 5 taken 25191 times.
809450 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8690 25191 return;
8691
8692 784259 int32_t tempy=yofs;
8693 784259 int32_t fdiv = frate/4;
8694
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8695
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8696 784259 efrate:((clk>=(frate>>1))?1:0);
8697 784259 flip = 0;
8698 784259 shadowtile = wpnsbuf[spr_shadow].tile;
8699
8700
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 if(get_qr(qr_NEWENEMYTILES))
8701 {
8702
2/2
✓ Branch 0 taken 581728 times.
✓ Branch 1 taken 202531 times.
784259 if(misc==0)
8703 {
8704 202531 shadowtile+=f2;
8705 202531 }
8706
2/2
✓ Branch 0 taken 259363 times.
✓ Branch 1 taken 322365 times.
581728 else if(misc!=1)
8707 322365 shadowtile+=2;
8708 784259 }
8709 else
8710 {
8711 if(misc==0)
8712 {
8713 shadowtile += f2 ? 1 : 0;
8714 }
8715 else if(misc!=1)
8716 {
8717 ++shadowtile;
8718 }
8719 }
8720
8721 784259 yofs+=8;
8722
8723
4/4
✓ Branch 0 taken 606981 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 344816 times.
✓ Branch 3 taken 262165 times.
784259 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8724 {
8725
6/6
✓ Branch 0 taken 134327 times.
✓ Branch 1 taken 127838 times.
✓ Branch 2 taken 244709 times.
✓ Branch 3 taken 17456 times.
✓ Branch 4 taken 123717 times.
✓ Branch 5 taken 120992 times.
262165 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8726 262165 }
8727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784259 times.
784259 if(!shadow_overpit(this))
8728 784259 enemy::drawshadow(dest,translucent);
8729 784259 yofs=tempy;
8730 809450 }
8731
8732 2052032 void eTektite::draw(BITMAP *dest)
8733 {
8734 2052032 update_enemy_frame();
8735 2052032 enemy::draw(dest);
8736 2052032 }
8737
8738 732 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8739 732 {
8740
2/4
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 732 times.
✗ Branch 3 not taken.
732 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8741 732 superman=1;
8742 732 dir=8;
8743 732 hxofs=1000;
8744 732 mainguy=false;
8745 732 count_enemy=false;
8746
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
732 if (SIZEflags != 0) init_size_flags();;
8747 732 }
8748
8749 280245 bool eItemFairy::animate(int32_t index)
8750 {
8751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280245 times.
280245 if(switch_hooked) return enemy::animate(index);
8752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280245 times.
280245 if(dying)
8753 return Dead(index);
8754
8755 //if(clk>32)
8756 280245 misc=1;
8757 280245 bool w=watch;
8758 280245 watch=false;
8759 280245 variable_walk_8(misc?3:0,0,8,spw_floater);
8760 280245 watch=w;
8761
8762
2/2
✓ Branch 0 taken 1516 times.
✓ Branch 1 taken 278729 times.
280245 if(clk==0)
8763 {
8764 1516 removearmos(x,y,ffcactivated);
8765 1516 }
8766
8767 280245 return enemy::animate(index);
8768 280245 }
8769
8770 562846 void eItemFairy::draw(BITMAP *dest)
8771 {
8772 //these are here to bypass compiler warnings about unused arguments
8773 562846 dest=dest;
8774 562846 }
8775
8776 1825 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8777 1825 {
8778 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8779
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1825 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1825 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1825 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1825 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1825 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1825 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1825 times.
✗ Branch 19 not taken.
1825 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8780 1825 dir=8;
8781 1825 movestatus=1;
8782 1825 clk=0;
8783
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 step=0;
8784 //nets+720;
8785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if (SIZEflags != 0) init_size_flags();;
8786 1825 }
8787
8788 520615 bool ePeahat::animate(int32_t index)
8789 {
8790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520615 times.
520615 if(switch_hooked) return enemy::animate(index);
8791
2/4
✓ Branch 0 taken 520615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 520615 times.
520615 if(fallclk||drownclk) return enemy::animate(index);
8792
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 520537 times.
520615 if(slide())
8793 {
8794 78 return false;
8795 }
8796
8797
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 519507 times.
520537 if(dying)
8798 1030 return Dead(index);
8799
8800
2/2
✓ Branch 0 taken 3083 times.
✓ Branch 1 taken 516424 times.
519507 if(clk==0)
8801 {
8802 3083 removearmos(x,y,ffcactivated);
8803 3083 }
8804
8805
4/4
✓ Branch 0 taken 516389 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 253336 times.
✓ Branch 3 taken 263053 times.
519507 if(stunclk==0 && clk>96)
8806 263053 misc=1;
8807
8808
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
519507 if(!watch)
8809
2/2
✓ Branch 0 taken 171491 times.
✓ Branch 1 taken 345614 times.
517105 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8810
8811
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
519507 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8812 {
8813
1/2
✓ Branch 0 taken 100018 times.
✗ Branch 1 not taken.
100018 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8814 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8815 100018 }
8816
8817
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
519507 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8818 1634 superman=0;
8819 else
8820
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 508062 times.
517873 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8821 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8822
2/2
✓ Branch 0 taken 264937 times.
✓ Branch 1 taken 254570 times.
519507 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8823 {
8824
2/2
✓ Branch 0 taken 261822 times.
✓ Branch 1 taken 3115 times.
264937 if ( stunclk ) --stunclk;
8825 264937 }
8826 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8827 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8828
8829
8830
2/2
✓ Branch 0 taken 519267 times.
✓ Branch 1 taken 240 times.
519507 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8831
8832 519507 return enemy::animate(index);
8833 520615 }
8834
8835 334520 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8836 {
8837 334520 int32_t tempy=yofs;
8838 334520 flip = 0;
8839 334520 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8840
8841
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 246431 times.
334520 if(!get_qr(qr_ENEMIESZAXIS))
8842 {
8843 246431 yofs+=8;
8844 246431 yofs+=int32_t(step/zslongToFix(dstep*10));
8845 246431 }
8846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334520 times.
334520 if(!shadow_overpit(this))
8847 334520 enemy::drawshadow(dest,translucent);
8848 334520 yofs=tempy;
8849 334520 }
8850
8851 1144330 void ePeahat::draw(BITMAP *dest)
8852 {
8853 1144330 update_enemy_frame();
8854 1144330 enemy::draw(dest);
8855 1144330 }
8856
8857 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8858 {
8859 4136 int32_t wpnId = w->id;
8860 4136 int32_t enemyHitWeapon = w->parentitem;
8861
8862
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8863 return 0;
8864
8865
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8866 // fire boomerang, for nailing peahats
8867
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8868 3343 return 0;
8869
8870 // Time for a kludge...
8871 793 int32_t s = superman;
8872 793 superman = 0;
8873 793 int32_t ret = enemy::takehit(w,realweap);
8874 793 superman = s;
8875
8876 // Anyway...
8877
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8878 {
8879 192 clk2=0;
8880 192 movestatus=0;
8881 192 misc=0;
8882 192 clk=0;
8883 192 step=0;
8884 192 }
8885
8886 793 return ret;
8887 4136 }
8888
8889 // auomatically kill off enemy (for rooms with ringleaders)
8890 void ePeahat::kickbucket()
8891 {
8892 hp=-1000; // don't call death_sfx()
8893 }
8894
8895 3942 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8896 3942 {
8897 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8898
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 2147 times.
3942 if(dmisc1==0)
8899 {
8900 2147 misc=-1; //Line of Sight leevers
8901 2147 clk-=16;
8902 2147 }
8903 3942 clk3 = 0;
8904 //nets+1460;
8905 3942 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8906 3942 submerged = false;
8907
1/4
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if (SIZEflags != 0) init_size_flags();;
8908 3942 }
8909
8910 923 bool eLeever::isSubmerged() const
8911 {
8912 923 Z_scripterrlog("misc is: %d\n", misc);
8913 923 return misc <= 0;
8914
8915 }
8916
8917 1018478 bool eLeever::animate(int32_t index)
8918 {
8919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1018478 times.
1018478 if(switch_hooked) return enemy::animate(index);
8920
3/4
✓ Branch 0 taken 1018123 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1018123 times.
1018478 if(fallclk||drownclk)
8921 {
8922 355 return enemy::animate(index);
8923 }
8924
2/2
✓ Branch 0 taken 31552 times.
✓ Branch 1 taken 986571 times.
1018123 if(dying)
8925 31552 return Dead(index);
8926
8927
2/2
✓ Branch 0 taken 941601 times.
✓ Branch 1 taken 44970 times.
986571 if(clk==0)
8928 {
8929 44970 removearmos(x,y,ffcactivated);
8930 44970 }
8931
8932
4/4
✓ Branch 0 taken 816947 times.
✓ Branch 1 taken 169624 times.
✓ Branch 2 taken 5265 times.
✓ Branch 3 taken 811682 times.
986571 if(clk>=0 && !slide())
8933 {
8934
2/2
✓ Branch 0 taken 337868 times.
✓ Branch 1 taken 473814 times.
811682 switch(dmisc1)
8935 {
8936 case 0: //line of sight
8937 case 2:
8938
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 124459 times.
✓ Branch 2 taken 49109 times.
✓ Branch 3 taken 35464 times.
✓ Branch 4 taken 15780 times.
✓ Branch 5 taken 101784 times.
✓ Branch 6 taken 4365 times.
✓ Branch 7 taken 6907 times.
337868 switch(misc) //is this leever active
8939 {
8940 case -1: //submerged
8941 {
8942
4/6
✓ Branch 0 taken 6382 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 6382 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6382 times.
124459 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8943
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 114160 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
124459 if((dmisc1==2)&&(zc_oldrand()&255))
8944 {
8945 10261 break;
8946 }
8947
8948 114198 int32_t active=0;
8949
8950
2/2
✓ Branch 0 taken 783342 times.
✓ Branch 1 taken 114198 times.
897540 for(int32_t i=0; i<guys.Count(); i++)
8951 {
8952
4/4
✓ Branch 0 taken 627294 times.
✓ Branch 1 taken 156048 times.
✓ Branch 2 taken 401598 times.
✓ Branch 3 taken 225696 times.
783342 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8953 {
8954 225696 ++active;
8955 225696 }
8956 783342 }
8957
8958
2/2
✓ Branch 0 taken 112327 times.
✓ Branch 1 taken 1871 times.
114198 if(active<((dmisc1==2)?1:2))
8959 {
8960 1871 misc=0; //activate this one
8961 1871 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8962 1871 }
8963 }
8964 114198 break;
8965
8966 case 0:
8967 {
8968
8969
4/6
✓ Branch 0 taken 11920 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 11920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11920 times.
49109 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8970 {
8971 misc=1;
8972 clk2=0;
8973 }
8974
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 49052 times.
49109 else if (clk3<=0)
8975 {
8976 57 misc = -1;
8977 57 break;
8978 }
8979 49052 int32_t s=0;
8980
8981
2/2
✓ Branch 0 taken 273250 times.
✓ Branch 1 taken 49052 times.
322302 for(int32_t i=0; i<guys.Count(); i++)
8982 {
8983
4/4
✓ Branch 0 taken 164314 times.
✓ Branch 1 taken 108936 times.
✓ Branch 2 taken 156432 times.
✓ Branch 3 taken 7882 times.
273250 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8984 {
8985 7882 ++s;
8986 7882 }
8987 273250 }
8988
8989
2/2
✓ Branch 0 taken 7882 times.
✓ Branch 1 taken 41170 times.
49052 if(s>0)
8990 {
8991 7882 break;
8992 }
8993
8994 41170 int32_t d2=zc_oldrand()&1;
8995
8996
2/2
✓ Branch 0 taken 14509 times.
✓ Branch 1 taken 26661 times.
41170 if(HeroDir()>=left)
8997 {
8998 26661 d2+=2;
8999 26661 }
9000
9001
4/4
✓ Branch 0 taken 39722 times.
✓ Branch 1 taken 1448 times.
✓ Branch 2 taken 663 times.
✓ Branch 3 taken 39059 times.
41170 if(canplace(d2) || canplace(d2^1))
9002 {
9003 2111 misc=1;
9004 2111 clk2=0;
9005 2111 clk=0;
9006 2111 }
9007 }
9008 41170 break;
9009
9010 case 1:
9011
9012
7/8
✓ Branch 0 taken 33397 times.
✓ Branch 1 taken 2067 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 3596 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 3595 times.
35464 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
9013
9014 35464 break;
9015
9016 case 2:
9017
9018
7/8
✓ Branch 0 taken 13865 times.
✓ Branch 1 taken 1915 times.
✓ Branch 2 taken 1503 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1503 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1502 times.
15780 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
9019
9020 15780 break;
9021
9022 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
9023 case 3:
9024
9025
5/6
✓ Branch 0 taken 98195 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 98195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 95468 times.
101784 if(stunclk || frozenclock || watch) break;
9026
9027
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 95326 times.
95468 if(scored) dir^=1;
9028
9029
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 94963 times.
95468 if(!canmove(dir,false)) misc=4;
9030 94963 else move(zslongToFix(dstep*100));
9031
9032 95468 break;
9033
9034 case 4:
9035
4/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 610 times.
4365 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9036
2/2
✓ Branch 0 taken 3897 times.
✓ Branch 1 taken 468 times.
4365 if(--clk2<=16)
9037 {
9038 468 misc=5;
9039 468 clk=8;
9040 468 }
9041
9042 4365 break;
9043
9044 case 5:
9045
5/6
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1009 times.
6907 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9046
2/2
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 410 times.
6907 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9047
9048 6907 break;
9049 } // switch(misc)
9050
9051 337868 break;
9052
9053 default: //random
9054 // step=d->misc3/100.0;
9055
9056 473814 step=zslongToFix(dmisc3*100);
9057
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
473814 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9058 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9059 {
9060 if (clk2 < 48) clk2+=2;
9061 if (clk2 >= 300) clk2-=2;
9062 }
9063
9064
2/2
✓ Branch 0 taken 60840 times.
✓ Branch 1 taken 412974 times.
473814 if(clk2<32) misc=1;
9065
2/2
✓ Branch 0 taken 30244 times.
✓ Branch 1 taken 382730 times.
412974 else if(clk2<48) misc=2;
9066
2/2
✓ Branch 0 taken 289541 times.
✓ Branch 1 taken 93189 times.
382730 else if(clk2<300)
9067 {
9068 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9069 {
9070 fix_coords();
9071 }*/
9072 289541 misc=3;
9073 289541 step = zslongToFix(dstep*100);
9074 289541 }
9075
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 84180 times.
93189 else if(clk2<316) misc=2;
9076
2/2
✓ Branch 0 taken 43755 times.
✓ Branch 1 taken 40425 times.
84180 else if(clk2<412) misc=1;
9077
2/2
✓ Branch 0 taken 40151 times.
✓ Branch 1 taken 274 times.
40425 else if(clk2<540)
9078 {
9079 40151 misc=0;
9080 40151 step=0;
9081 40151 }
9082 274 else clk2=0;
9083
9084
2/2
✓ Branch 0 taken 471961 times.
✓ Branch 1 taken 1853 times.
473814 if(clk2==48) clk=0;
9085
9086 // variable_walk(d->rate, d->homing, 0);
9087 473814 variable_walk(rate, homing, 0);
9088 473814 } // switch(dmisc1)
9089 811682 }
9090
9091 986571 hxofs=(misc>=2)?0:1000;
9092 986571 return enemy::animate(index);
9093 1018478 }
9094
9095 80892 bool eLeever::canplace(int32_t d2)
9096 {
9097 80892 int32_t nx=HeroX();
9098 80892 int32_t ny=HeroY();
9099
9100
2/2
✓ Branch 0 taken 28492 times.
✓ Branch 1 taken 52400 times.
80892 if(d2<left) ny=TRUNCATE_TILE(ny);
9101 52400 else nx=TRUNCATE_TILE(nx);
9102
9103
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14174 times.
✓ Branch 2 taken 14318 times.
✓ Branch 3 taken 26181 times.
✓ Branch 4 taken 26219 times.
80892 switch(d2)
9104 {
9105 case up:
9106
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 30 times.
14174 ny-=((dmisc1==0||dmisc1==2)?32:48);
9107 14174 break;
9108
9109 case down:
9110
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14284 times.
14318 ny+=((dmisc1==0||dmisc1==2)?32:48);
9111
9112
4/4
✓ Branch 0 taken 10087 times.
✓ Branch 1 taken 4231 times.
✓ Branch 2 taken 10076 times.
✓ Branch 3 taken 11 times.
14318 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9113
9114 14318 break;
9115
9116 case left:
9117
2/2
✓ Branch 0 taken 25528 times.
✓ Branch 1 taken 653 times.
26181 nx-=((dmisc1==0||dmisc1==2)?32:48);
9118 26181 break;
9119
9120 case right:
9121
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 25573 times.
26219 nx+=((dmisc1==0||dmisc1==2)?32:48);
9122
9123
4/4
✓ Branch 0 taken 19151 times.
✓ Branch 1 taken 7068 times.
✓ Branch 2 taken 18549 times.
✓ Branch 3 taken 602 times.
26219 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9124
9125 26219 break;
9126 }
9127
9128
4/4
✓ Branch 0 taken 20429 times.
✓ Branch 1 taken 60463 times.
✓ Branch 2 taken 9001 times.
✓ Branch 3 taken 11428 times.
80892 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9129 69464 return false;
9130
9131
2/2
✓ Branch 0 taken 865 times.
✓ Branch 1 taken 10563 times.
11428 if(d2>=left)
9132
4/4
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 5538 times.
✓ Branch 2 taken 9317 times.
✓ Branch 3 taken 1246 times.
10563 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9133 9317 return false;
9134
9135 2111 x=nx;
9136 2111 y=ny;
9137 2111 dir=d2^1;
9138 2111 return true;
9139 80892 }
9140
9141 1024382 void eLeever::draw(BITMAP *dest)
9142 {
9143 // cs=d->cset;
9144 1024382 cs=dcset;
9145 1024382 update_enemy_frame();
9146
3/4
✓ Branch 0 taken 1024027 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1024027 times.
1024382 if(!fallclk&&!drownclk)
9147 {
9148
2/2
✓ Branch 0 taken 637088 times.
✓ Branch 1 taken 386939 times.
1024027 switch(misc)
9149 {
9150 case -1:
9151 case 0:
9152 386939 return;
9153 }
9154 637088 }
9155
9156 637443 enemy::draw(dest);
9157 1024382 }
9158
9159 998 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9160 998 {
9161 998 hashero=false;
9162 //nets+1000;
9163
1/4
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if (SIZEflags != 0) init_size_flags();;
9164 998 }
9165
9166 504762 bool eWallM::animate(int32_t index)
9167 {
9168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504762 times.
504762 if(switch_hooked) return enemy::animate(index);
9169
2/4
✓ Branch 0 taken 504762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 504762 times.
504762 if(fallclk||drownclk)
9170 {
9171 return enemy::animate(index);
9172 }
9173
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 494906 times.
504762 if(dying)
9174 9856 return Dead(index);
9175
9176
2/2
✓ Branch 0 taken 463930 times.
✓ Branch 1 taken 30976 times.
494906 if(clk==0)
9177 {
9178 30976 removearmos(x,y,ffcactivated);
9179 30976 }
9180
9181 494906 hxofs=1000;
9182
2/2
✓ Branch 0 taken 117732 times.
✓ Branch 1 taken 377174 times.
494906 if(misc==0) //inside wall, ready to spawn?
9183 {
9184
4/4
✓ Branch 0 taken 228512 times.
✓ Branch 1 taken 148662 times.
✓ Branch 2 taken 16723 times.
✓ Branch 3 taken 211789 times.
377174 if(frame-wallm_load_clk>80 && clk>=0)
9185 {
9186 211789 int32_t wall=hero_on_wall();
9187 211789 int32_t wallm_cnt=0;
9188
9189
2/2
✓ Branch 0 taken 1670618 times.
✓ Branch 1 taken 211789 times.
1882407 for(int32_t i=0; i<guys.Count(); i++)
9190
2/2
✓ Branch 0 taken 657527 times.
✓ Branch 1 taken 1013091 times.
2683709 if(((enemy*)guys.spr(i))->family==eeWALLM)
9191 {
9192 1013091 int32_t m=((enemy*)guys.spr(i))->misc;
9193
9194
4/4
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 962987 times.
✓ Branch 2 taken 36738 times.
✓ Branch 3 taken 13366 times.
1013091 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9195 {
9196 13366 ++wallm_cnt;
9197 13366 }
9198 1013091 }
9199
9200
2/2
✓ Branch 0 taken 210948 times.
✓ Branch 1 taken 841 times.
211789 if(wall>0)
9201 {
9202 841 --wall;
9203 841 misc=1; //emerging from the wall?
9204 841 clk2=0;
9205 841 clk3=wall^1;
9206 841 wallm_load_clk=frame;
9207
9208
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 327 times.
841 if(wall<=down)
9209 {
9210
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 423 times.
514 if(HeroDir()==left)
9211 91 dir=right;
9212 else
9213 423 dir=left;
9214 514 }
9215 else
9216 {
9217
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 261 times.
327 if(HeroDir()==up)
9218 66 dir=down;
9219 else
9220 261 dir=up;
9221 }
9222
9223
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 104 times.
841 switch(wall)
9224 {
9225 case up:
9226 231 y=0;
9227 231 break;
9228
9229 case down:
9230 283 y=160;
9231 283 break;
9232
9233 case left:
9234 223 x=0;
9235 223 break;
9236
9237 case right:
9238 104 x=240;
9239 104 break;
9240 }
9241
9242
9243
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 91 times.
841 switch(dir)
9244 {
9245 case up:
9246 261 y=(HeroY()+48-(wallm_cnt&1)*12);
9247 261 flip=wall&1;
9248 261 break;
9249
9250 case down:
9251 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9252 66 flip=((wall&1)^1)+2;
9253 66 break;
9254
9255 case left:
9256 423 x=(HeroX()+48-(wallm_cnt&1)*12);
9257 423 flip=(wall==up?2:0)+1;
9258 423 break;
9259
9260 case right:
9261 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9262 91 flip=(wall==up?2:0);
9263 91 break;
9264 }
9265
9266 841 }
9267 211789 }
9268 377174 }
9269 else
9270 117732 wallm_crawl();
9271
9272 494906 return enemy::animate(index);
9273 504762 }
9274
9275 117732 void eWallM::wallm_crawl()
9276 {
9277 117732 bool w=watch;
9278 117732 hxofs=0;
9279
9280
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 116922 times.
117732 if(slide())
9281 {
9282 810 return;
9283 }
9284
9285 // if(dying || watch || (!hashero && stunclk))
9286
6/8
✓ Branch 0 taken 116922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115593 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 101047 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101047 times.
116922 if(dying || (!hashero && ( stunclk || frozenclock )))
9287 {
9288 14546 return;
9289 }
9290
9291 102376 watch=false;
9292 102376 ++clk2;
9293 // Misc1: slightly different movement
9294 102376 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9295
9296 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102376 times.
102376 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9298
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 96159 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
102376 if(w&&misc>=3&&misc<=5)
9299 {
9300 4491 --clk2;
9301 4491 }
9302
9303
4/4
✓ Branch 0 taken 39396 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 9984 times.
✓ Branch 3 taken 144 times.
102376 switch(misc)
9304 {
9305 case 1:
9306 case 2:
9307 52852 zc_swap(dir,clk3);
9308 52852 move(step);
9309 52852 zc_swap(dir,clk3);
9310 52852 break;
9311
9312 case 3:
9313 case 4:
9314 case 5:
9315
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34905 times.
39396 if(w)
9316 {
9317 4491 watch=w;
9318 4491 return;
9319 }
9320
9321 34905 move(step);
9322 34905 break;
9323
9324 case 6:
9325 case 7:
9326 9984 zc_swap(dir,clk3);
9327 9984 dir^=1;
9328 9984 move(step);
9329 9984 dir^=1;
9330 9984 zc_swap(dir,clk3);
9331 9984 break;
9332
9333 default:
9334 144 misc=0;
9335 144 break;
9336 }
9337
9338 97885 watch=w;
9339 117732 }
9340
9341 9 void eWallM::grabhero()
9342 {
9343 9 hashero=true;
9344 9 superman=1;
9345 9 }
9346
9347 507147 void eWallM::draw(BITMAP *dest)
9348 {
9349 507147 dummy_bool[1]=hashero;
9350 507147 update_enemy_frame();
9351
9352
4/6
✓ Branch 0 taken 377966 times.
✓ Branch 1 taken 129181 times.
✓ Branch 2 taken 377966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377966 times.
507147 if(misc>0 || fallclk||drownclk)
9353 {
9354 129181 masked_draw(dest,16,playing_field_offset+16,224,144);
9355 129181 }
9356
9357 // enemy::draw(dest);
9358 // tile = clk&8 ? 128:129;
9359 507147 }
9360
9361 bool eWallM::isSubmerged() const
9362 {
9363 return ( !misc );
9364 }
9365
9366 1640 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9367 1640 {
9368
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 ox=x; //original x
9369
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 oy=y; //original y
9370
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 166 times.
1640 if(get_qr(qr_TRAPPOSFIX))
9371 {
9372
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
166 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9373 166 }
9374
9375 1640 mainguy=false;
9376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
1640 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9377 //nets+420;
9378 1640 dummy_int[1]=0;
9379
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1640 if (SIZEflags != 0) init_size_flags();;
9380 1640 }
9381
9382 1042165 bool eTrap::animate(int32_t index)
9383 {
9384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1042165 times.
1042165 if(switch_hooked) return enemy::animate(index);
9385
2/4
✓ Branch 0 taken 1042165 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1042165 times.
1042165 if(fallclk||drownclk) return enemy::animate(index);
9386
2/2
✓ Branch 0 taken 1020511 times.
✓ Branch 1 taken 21654 times.
1042165 if(clk<0)
9387 21654 return enemy::animate(index);
9388
9389
2/2
✓ Branch 0 taken 955962 times.
✓ Branch 1 taken 64549 times.
1020511 if(clk==0)
9390 {
9391 64549 removearmos(x,y,ffcactivated);
9392 64549 }
9393
9394
2/2
✓ Branch 0 taken 319209 times.
✓ Branch 1 taken 701302 times.
1020511 if(misc==0) // waiting
9395 {
9396 701302 ox = x;
9397 701302 oy = y;
9398 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9399 701302 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9400
9401
4/4
✓ Branch 0 taken 241777 times.
✓ Branch 1 taken 459525 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 108261 times.
701302 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9402 {
9403 108261 dir=down;
9404 108261 }
9405
4/4
✓ Branch 0 taken 393308 times.
✓ Branch 1 taken 199733 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 259792 times.
593041 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9406 {
9407 259792 dir=right;
9408 259792 }
9409
4/4
✓ Branch 0 taken 212039 times.
✓ Branch 1 taken 121210 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 78523 times.
333249 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9410 {
9411 78523 dir=up;
9412 78523 }
9413 else
9414 {
9415 254726 dir=left;
9416 }
9417
9418 701302 int32_t d2=lined_up(15,true);
9419
9420
4/4
✓ Branch 0 taken 268741 times.
✓ Branch 1 taken 432561 times.
✓ Branch 2 taken 1107234 times.
✓ Branch 3 taken 405932 times.
1095295 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9421
2/2
✓ Branch 0 taken 232564 times.
✓ Branch 1 taken 189236 times.
405932 ((d2>down) && (dmisc1==2)) ||
9422
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 52727 times.
189236 ((d2>right) && (!dmisc1)) ||
9423
2/2
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 154197 times.
239796 ((d2<l_up) && (dmisc1==4)) ||
9424
3/4
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 239796 times.
✓ Branch 2 taken 393993 times.
✗ Branch 3 not taken.
154197 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9425
3/4
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 154197 times.
✓ Branch 2 taken 393993 times.
✗ Branch 3 not taken.
239796 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9426 {
9427 2521777 d2=-1;
9428 2521777 }
9429
9430
4/4
✓ Branch 0 taken 20708 times.
✓ Branch 1 taken 440798 times.
✓ Branch 2 taken 18593 times.
✓ Branch 3 taken 2115 times.
461506 if(d2!=-1 && trapmove(d2))
9431 {
9432 2115 dir=d2;
9433 2115 misc=1;
9434 2115 clk2=(dir==down)?3:0;
9435 2115 }
9436 461506 }
9437
9438
2/2
✓ Branch 0 taken 691180 times.
✓ Branch 1 taken 89535 times.
780715 if(misc==1) // charging
9439 {
9440 89535 clk2=(clk2+1)&3;
9441 89535 step=(clk2==3)?1:2;
9442
9443
4/4
✓ Branch 0 taken 88731 times.
✓ Branch 1 taken 804 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 87626 times.
89535 if(!trapmove(dir) || clip())
9444 {
9445 1909 misc=2;
9446
9447
1/2
✓ Branch 0 taken 1909 times.
✗ Branch 1 not taken.
1909 if(dir<l_up)
9448 {
9449 1909 dir=dir^1;
9450 1909 }
9451 else
9452 {
9453 dir=dir^3;
9454 }
9455 1909 }
9456 else
9457 {
9458 87626 sprite::move(step);
9459 }
9460 89535 }
9461
9462
2/2
✓ Branch 0 taken 547017 times.
✓ Branch 1 taken 233698 times.
780715 if(misc==2) // retreating
9463 {
9464 233698 step=(++clk2&1)?1:0;
9465
9466
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 39011 times.
✓ Branch 2 taken 80947 times.
✓ Branch 3 taken 29129 times.
✓ Branch 4 taken 84611 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
233698 switch(dir)
9467 {
9468 case up:
9469
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 38739 times.
39011 if(int32_t(y)<=oy) goto trap_rest;
9470 38739 else sprite::move(step);
9471
9472 38739 break;
9473
9474 case left:
9475
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 80555 times.
80947 if(int32_t(x)<=ox) goto trap_rest;
9476 80555 else sprite::move(step);
9477
9478 80555 break;
9479
9480 case down:
9481
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 28905 times.
29129 if(int32_t(y)>=oy) goto trap_rest;
9482 28905 else sprite::move(step);
9483
9484 28905 break;
9485
9486 case right:
9487
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 84176 times.
84611 if(int32_t(x)>=ox) goto trap_rest;
9488 84176 else sprite::move(step);
9489
9490 84176 break;
9491
9492 case l_up:
9493 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9494 else sprite::move(step);
9495
9496 break;
9497
9498 case r_up:
9499 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9500 else sprite::move(step);
9501
9502 break;
9503
9504 case l_down:
9505 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9506 else sprite::move(step);
9507
9508 break;
9509
9510 case r_down:
9511 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9512 else sprite::move(step);
9513
9514 break;
9515 trap_rest:
9516 {
9517 1323 x=ox;
9518 1323 y=oy;
9519 1323 misc=0;
9520 }
9521 1323 }
9522 233698 }
9523
9524 780715 return enemy::animate(index);
9525 802369 }
9526
9527 110243 bool eTrap::trapmove(int32_t ndir)
9528 {
9529
2/2
✓ Branch 0 taken 80479 times.
✓ Branch 1 taken 29764 times.
110243 if(get_qr(qr_MEANTRAPS))
9530 {
9531 80479 mapscr* scr = get_scr(screen_spawned);
9532
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 79139 times.
80479 if(scr->flags2&fFLOATTRAPS)
9533 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9534
9535 79139 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9536 }
9537
9538
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9539 4730 return false;
9540
9541
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9542 return false;
9543
9544
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9545 return false;
9546
9547
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9548 return false;
9549
9550
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9551 4722 return false;
9552
9553
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9554 713 return false;
9555
9556
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9557 return false;
9558
9559
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9560 return false;
9561
9562
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9563 return false;
9564
9565
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9566 return false;
9567
9568 19599 return true;
9569 110243 }
9570
9571 88731 bool eTrap::clip()
9572 {
9573
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 45709 times.
88731 if(get_qr(qr_MEANPLACEDTRAPS))
9574 {
9575
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
✓ Branch 2 taken 8656 times.
✓ Branch 3 taken 16039 times.
✓ Branch 4 taken 15222 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
45709 switch(dir)
9576 {
9577 case up:
9578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
5792 if(y<=0) return true;
9579
9580 5792 break;
9581
9582 case down:
9583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8656 times.
8656 if(y>=world_h-16) return true;
9584
9585 8656 break;
9586
9587 case left:
9588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16039 times.
16039 if(x<=0) return true;
9589
9590 16039 break;
9591
9592 case right:
9593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15222 times.
15222 if(x>=world_w-16) return true;
9594
9595 15222 break;
9596
9597 case l_up:
9598 if(y<=0||x<=0) return true;
9599
9600 break;
9601
9602 case l_down:
9603 if(y>=world_h-16||x<=0) return true;
9604
9605 break;
9606
9607 case r_up:
9608 if(y<=0||x>=world_w-16) return true;
9609
9610 break;
9611
9612 case r_down:
9613 if(y>=world_h-16||x>=world_w-16) return true;
9614
9615 break;
9616 }
9617
9618 45709 return false;
9619 }
9620 else
9621 {
9622
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9623 {
9624 case up:
9625
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9626
9627 4695 break;
9628
9629 case down:
9630
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9631
9632 5253 break;
9633
9634 case left:
9635
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9636
9637 16376 break;
9638
9639 case right:
9640
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9641
9642 15593 break;
9643
9644 case l_up:
9645 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9646
9647 break;
9648
9649 case l_down:
9650 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9651
9652 break;
9653
9654 case r_up:
9655 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9656
9657 break;
9658
9659 case r_down:
9660 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9661
9662 break;
9663 }
9664
9665 41917 return false;
9666 }
9667 88731 }
9668
9669 1061079 void eTrap::draw(BITMAP *dest)
9670 {
9671 1061079 update_enemy_frame();
9672 1061079 enemy::draw(dest);
9673 1061079 }
9674
9675 5705 int32_t eTrap::takehit(weapon*,weapon*)
9676 {
9677 5705 return 0;
9678 }
9679
9680 832 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9681 832 {
9682 832 lasthit=-1;
9683 832 lasthitclk=0;
9684 832 mainguy=false;
9685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9686
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 step=2;
9687
3/6
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9688 {
9689
2/4
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
399 dir=(x<=112)?right:left;
9690 399 }
9691 else
9692 {
9693
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
433 dir=(y<=72)?down:up;
9694 }
9695
9696
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 72 times.
832 if(get_qr(qr_TRAPPOSFIX))
9697 {
9698
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9699 72 }
9700
9701 //nets+((id==eTRAP_LR)?540:520);
9702 832 dummy_int[1]=0;
9703
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if (SIZEflags != 0) init_size_flags();;
9704 832 }
9705
9706 346559 bool eTrap2::animate(int32_t index)
9707 {
9708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 346559 times.
346559 if(switch_hooked) return enemy::animate(index);
9709
2/4
✓ Branch 0 taken 346559 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 346559 times.
346559 if(fallclk||drownclk) return enemy::animate(index);
9710
2/2
✓ Branch 0 taken 335533 times.
✓ Branch 1 taken 11026 times.
346559 if(clk<0)
9711 11026 return enemy::animate(index);
9712
9713
2/2
✓ Branch 0 taken 21385 times.
✓ Branch 1 taken 314148 times.
335533 if(clk==0)
9714 {
9715 21385 removearmos(x,y,ffcactivated);
9716 21385 }
9717
9718
2/2
✓ Branch 0 taken 211207 times.
✓ Branch 1 taken 124326 times.
335533 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9719 {
9720
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9721 {
9722 11074 --lasthitclk;
9723 11074 }
9724 else
9725 {
9726 113252 lasthit=-1;
9727 }
9728
9729 124326 bool hitenemy=false;
9730
9731
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9732 {
9733
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9734 {
9735
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9736 {
9737 3669 lasthit=j;
9738 3669 lasthitclk=10;
9739 3669 hitenemy=true;
9740 3669 guys.spr(j)->lasthit=index;
9741 3669 guys.spr(j)->lasthitclk=10;
9742 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9743 3669 }
9744 730351 }
9745 864860 }
9746
9747
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9748 {
9749
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9750 {
9751 3155 lasthit=-1;
9752 3155 lasthitclk=0;
9753 3155 }
9754
9755
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9756 362 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9757
9758 5986 dir=dir^1;
9759 5986 }
9760
9761 124326 sprite::move(step);
9762 124326 }
9763 else
9764 {
9765
3/4
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 6919 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204288 times.
211207 if(!trapmove(dir) || clip())
9766 {
9767
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 1521 times.
6919 if(get_qr(qr_MORESOUNDS))
9768 1521 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9769
9770 6919 dir=dir^1;
9771 6919 }
9772
9773 211207 sprite::move(step);
9774 }
9775
9776 335533 return enemy::animate(index);
9777 346559 }
9778
9779 341519 bool eTrap2::trapmove(int32_t ndir)
9780 {
9781 341519 mapscr* scr = get_scr(screen_spawned);
9782
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 339641 times.
341519 if(scr->flags2&fFLOATTRAPS)
9783 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9784
9785 339641 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9786 341519 }
9787
9788 328290 bool eTrap2::clip()
9789 {
9790
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 88320 times.
✓ Branch 2 taken 89029 times.
✓ Branch 3 taken 75153 times.
✓ Branch 4 taken 75788 times.
328290 switch(dir)
9791 {
9792 case up:
9793
1/2
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
88320 if(y<=0) return true;
9794
9795 88320 break;
9796
9797 case down:
9798
1/2
✓ Branch 0 taken 89029 times.
✗ Branch 1 not taken.
89029 if(y>=world_h-16) return true;
9799
9800 89029 break;
9801
9802 case left:
9803
1/2
✓ Branch 0 taken 75153 times.
✗ Branch 1 not taken.
75153 if(x<=0) return true;
9804
9805 75153 break;
9806
9807 case right:
9808
1/2
✓ Branch 0 taken 75788 times.
✗ Branch 1 not taken.
75788 if(x>=world_w-16) return true;
9809
9810 75788 break;
9811 }
9812
9813 328290 return false;
9814 328290 }
9815
9816 350933 void eTrap2::draw(BITMAP *dest)
9817 {
9818 350933 update_enemy_frame();
9819 350933 enemy::draw(dest);
9820 350933 }
9821
9822 3169 int32_t eTrap2::takehit(weapon*,weapon*)
9823 {
9824 3169 return 0;
9825 }
9826
9827 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9828 354 {
9829 //do not show "enemy appering" anim -DD
9830 354 clk=0;
9831 354 mainguy=false;
9832 354 clk2=-14;
9833 //Enemy Editor Size Tab
9834
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9835 //nets+1640;
9836 354 }
9837
9838 354 void eRock::init_size_flags()
9839 {
9840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9841 354 else hxofs = -2;
9842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9843 354 else hyofs = -2;
9844
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9845 354 else hit_width = 20;
9846
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9847 354 else hit_height = 20;
9848
9849
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9850
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9851
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9852
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9853
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
9854 {
9855 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9856 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9857 }
9858
9859
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9860 354 }
9861
9862 121997 bool eRock::animate(int32_t index)
9863 {
9864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9865
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9867 return Dead(index);
9868
9869
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9870 {
9871 8376 removearmos(x,y,ffcactivated);
9872 8376 }
9873
9874
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9875 {
9876 697 x=zc_oldrand()&0xF0;
9877 697 y=0;
9878 697 clk3=0;
9879 697 clk2=zc_oldrand()&15;
9880 697 }
9881
9882
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9883 {
9884
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9885 {
9886 3430 dir=zc_oldrand()&1;
9887
9888
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9889
9890
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9891 3430 }
9892
9893
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9894 {
9895 95993 x += dir ? 1 : -1; //right, left
9896 95993 dummy_int[1]=dir;
9897
9898
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9899 {
9900 6852 y-=2; //up
9901 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9902 6852 }
9903
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9904 {
9905 10208 y--; //up
9906 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9907 10208 }
9908
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9909 {
9910 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9911 10135 }
9912
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9913 {
9914 10058 y++; //down
9915 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9916 10058 }
9917 else
9918 {
9919 58740 y+=2; //down
9920 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9921 }
9922
9923 95993 ++clk3;
9924 95993 }
9925
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<world_h)
9926 2761 clk3=0; // next bounce
9927 else
9928 423 clk2 = -(zc_oldrand()&63); // back to top
9929 99177 }
9930
9931 121997 return enemy::animate(index);
9932 121997 }
9933
9934 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9935 {
9936
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(clk2>=0)
9937 {
9938 44250 int32_t tempy=yofs;
9939 44250 flip = 0;
9940 44250 int32_t fdiv = frate/4;
9941
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9942
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9943 44250 efrate:((clk>=(frate>>1))?1:0);
9944 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9945
9946 44250 yofs+=8;
9947
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44250 times.
44250 if(!shadow_overpit(this))
9949 44250 sprite::drawshadow(dest, translucent);
9950 44250 yofs=tempy;
9951 44250 }
9952 51441 }
9953
9954 122078 void eRock::draw(BITMAP *dest)
9955 {
9956
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9957 {
9958 105043 int32_t tempdir=dir;
9959 105043 dir=dummy_int[2];
9960 105043 update_enemy_frame();
9961 105043 enemy::draw(dest);
9962 105043 dir=tempdir;
9963 105043 }
9964 122078 }
9965
9966 1014 int32_t eRock::takehit(weapon*,weapon*)
9967 {
9968 1014 return 0;
9969 }
9970
9971 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9972 30 {
9973 30 clk=0;
9974 30 mainguy=false;
9975 30 clk2=-14;
9976
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9977 //nets+1680;
9978 30 }
9979
9980 4440 bool eBoulder::animate(int32_t index)
9981 {
9982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9983
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9985 return Dead(index);
9986
9987
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9988 {
9989 290 removearmos(x,y,ffcactivated);
9990 290 }
9991
9992 zfix *vert;
9993
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
9994
9995
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
9996 {
9997 32 x=zc_oldrand()&0xF0;
9998 32 y=-32;
9999 32 clk3=0;
10000 32 clk2=zc_oldrand()&15;
10001 32 }
10002
10003
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
10004 {
10005
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
10006 {
10007 131 dir=zc_oldrand()&1;
10008
10009
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
10010
10011
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
10012 131 }
10013
10014
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
10015 {
10016 3487 x += dir ? 1 : -1; //right, left
10017 3487 dummy_int[1]=dir;
10018
10019
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
10020 {
10021 261 y-=2; //up
10022 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10023 261 }
10024
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
10025 {
10026 382 y--; //up
10027 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10028 382 }
10029
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10030 {
10031 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10032 376 }
10033
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10034 {
10035 367 y++; //down
10036 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10037 367 }
10038 else
10039 {
10040 2101 y+=2; //down
10041 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10042 }
10043
10044 3487 ++clk3;
10045 3487 }
10046
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10047 101 clk3=0; // next bounce
10048 else
10049 10 clk2 = -(zc_oldrand()&63); // back to top
10050 3598 }
10051
10052 4440 return enemy::animate(index);
10053 4440 }
10054
10055 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10056 {
10057
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
10058 {
10059 3868 int32_t tempy=yofs;
10060 3868 flip = 0;
10061 3868 int32_t f2=((clk<<2)/frate)<<1;
10062 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10063
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10064
10065 3868 yofs+=8;
10066 3868 xofs-=8;
10067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10068 3868 sprite::drawshadow(dest, translucent);
10069 3868 xofs+=16;
10070 3868 ++shadowtile;
10071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10072 3868 sprite::drawshadow(dest, translucent);
10073 3868 yofs+=16;
10074 3868 shadowtile+=20;
10075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10076 3868 sprite::drawshadow(dest, translucent);
10077 3868 xofs-=16;
10078 3868 --shadowtile;
10079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10080 3868 sprite::drawshadow(dest, translucent);
10081 3868 xofs+=8;
10082 3868 yofs=tempy;
10083 3868 }
10084 4440 }
10085
10086 4440 void eBoulder::draw(BITMAP *dest)
10087 {
10088
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10089 {
10090 3868 int32_t tempdir=dir;
10091 3868 dir=dummy_int[2];
10092 3868 update_enemy_frame();
10093 3868 dir=tempdir;
10094 3868 xofs-=8;
10095 3868 yofs-=8;
10096 3868 drawblock(dest,15);
10097 3868 xofs+=8;
10098 3868 yofs+=8;
10099 // enemy::draw(dest);
10100 3868 }
10101 4440 }
10102
10103 30 void eBoulder::init_size_flags()
10104 {
10105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10106 30 else hxofs = -10;
10107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10108 30 else hyofs = -10;
10109
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10110 30 else hit_width = 36;
10111
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10112 30 else hit_height = 36;
10113
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10114 30 else hzsz = 16; //can't be jumped
10115
10116
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10117
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10118
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10119
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10120
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
10121 {
10122 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10123 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10124 }
10125
10126
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10127 30 }
10128
10129 int32_t eBoulder::takehit(weapon*,weapon*)
10130 {
10131 return 0;
10132 }
10133
10134 4429 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10135
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3898 times.
4429 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10136 4429 {
10137 /* fixing
10138 hp=1;
10139 */
10140 4429 mainguy=false;
10141
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4422 times.
4429 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10142 4429 hclk=clk; // the "no fire" range
10143 4429 clk=0;
10144 4429 clk3=96;
10145 4429 timer=0;
10146
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4415 times.
4429 if(o_tile==0)
10147 {
10148 4415 superman=1;
10149 4415 hxofs=1000;
10150 4415 }
10151
1/4
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if (SIZEflags != 0) init_size_flags();;
10152 4429 }
10153
10154 2504746 bool eProjectile::animate(int32_t index)
10155 {
10156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504746 times.
2504746 if(switch_hooked) return enemy::animate(index);
10157
2/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2504746 times.
2504746 if(fallclk||drownclk) return enemy::animate(index);
10158
2/2
✓ Branch 0 taken 2492420 times.
✓ Branch 1 taken 12326 times.
2504746 if(clk==0)
10159 {
10160 12326 removearmos(x,y,ffcactivated);
10161 12326 }
10162
10163 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10164 2504746 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10165
10166
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669138 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2504746 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10167 {
10168 403631 dir=down;
10169 403631 }
10170
4/4
✓ Branch 0 taken 1348897 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 916920 times.
2101115 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10171 {
10172 916920 dir=right;
10173 916920 }
10174
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10175 {
10176 358900 dir=up;
10177 358900 }
10178 else
10179 {
10180 825295 dir=left;
10181 }
10182
10183
3/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306267 times.
✓ Branch 3 taken 1198479 times.
2504746 if(!stunclk && ++clk3>80)
10184 {
10185
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197433 times.
1198479 if(dmisc1==9) // Breath type
10186 {
10187
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10188 {
10189 563 unsigned r=zc_oldrand();
10190
10191
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10192 {
10193 6 timer=zc_oldrand()%50+50;
10194 6 }
10195 563 }
10196
10197
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10198 {
10199
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10200 {
10201 119 FireBreath(false);
10202 119 }
10203
10204
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10205 {
10206 6 clk3=0;
10207 6 }
10208 489 }
10209 1046 }
10210
10211 else // Not breath type
10212 {
10213 1197433 unsigned r=zc_oldrand();
10214
10215
4/4
✓ Branch 0 taken 18808 times.
✓ Branch 1 taken 1178625 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17542 times.
1197433 if(!(r&63) && !HeroInRange(minRange))
10216 {
10217 17542 FireWeapon();
10218
10219
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17794 if(get_qr(qr_BROKENSTATUES)==0 &&
10220
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10221 {
10222
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10223 {
10224 909 x-=4;
10225 909 FireWeapon();
10226 909 x+=4;
10227 909 }
10228 14854 }
10229
10230 17542 clk3=0;
10231 17542 }
10232 }
10233 1198479 }
10234
10235 2504746 return enemy::animate(index);
10236 2504746 }
10237
10238 2520335 void eProjectile::draw(BITMAP *dest)
10239 {
10240 2520335 update_enemy_frame();
10241 2520335 enemy::draw(dest);
10242 2520335 }
10243
10244 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10245 533 {
10246 533 hxofs=1000;
10247 533 }
10248
10249 249811 void eTrigger::draw(BITMAP *dest)
10250 {
10251 249811 update_enemy_frame();
10252 249811 enemy::draw(dest);
10253 249811 }
10254
10255 void eTrigger::death_sfx()
10256 {
10257 //silent death
10258 }
10259
10260 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10261 5 {
10262 5 o_tile+=wpnsbuf[iwNPCs].tile;
10263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10264 5 SIZEflags = d->SIZEflags;
10265
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10266 5 }
10267
10268 75 bool eNPC::animate(int32_t index)
10269 {
10270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10271
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10272 70 return Dead(index);
10273
10274
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10275 {
10276 removearmos(x,y,ffcactivated);
10277 }
10278
10279
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10280 {
10281 case 0:
10282 {
10283 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10284 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10285
10286
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10287 {
10288 dir=down;
10289 }
10290
10291
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10292 {
10293 5 dir=right;
10294 5 }
10295 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10296 {
10297 dir=up;
10298 }
10299 else
10300 {
10301 dir=left;
10302 }
10303 }
10304 5 break;
10305
10306 case 1:
10307 halting_walk(rate, homing, 0, hrate, 48);
10308
10309 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10310 {
10311 newdir(rate, homing, 0);
10312 clk2=48;
10313 ++misc;
10314 }
10315
10316 if(clk2==0)
10317 misc=0;
10318
10319 break;
10320 }
10321
10322 5 return enemy::animate(index);
10323 75 }
10324
10325 75 void eNPC::draw(BITMAP *dest)
10326 {
10327 75 update_enemy_frame();
10328 75 enemy::draw(dest);
10329 75 }
10330
10331 int32_t eNPC::takehit(weapon*,weapon*)
10332 {
10333 return 0;
10334 }
10335
10336 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10337 94 {
10338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10339 {
10340 94 o_tile=clk;
10341 94 cs=id>>12;
10342 94 }
10343
10344 94 id=id&0xFFF;
10345 94 clk=0;
10346
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10347 94 mainguy=false;
10348 94 SIZEflags = d->SIZEflags;
10349
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10350 94 }
10351
10352 81 void eSpinTile::facehero()
10353 {
10354
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10355 {
10356
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10357 1 dir = up;
10358 else
10359 dir = down;
10360 1 }
10361 else
10362 {
10363 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10364 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10365
10366
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10367 {
10368 12 dir=l_down;
10369 12 }
10370
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10371 {
10372 1 dir=down;
10373 1 }
10374
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10375 {
10376 12 dir=r_down;
10377 12 }
10378
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10379 {
10380 6 dir=right;
10381 6 }
10382
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10383 {
10384 17 dir=r_up;
10385 17 }
10386
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10387 {
10388 8 dir=up;
10389 8 }
10390
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10391 {
10392 6 dir=l_up;
10393 6 }
10394 else
10395 {
10396 18 dir=left;
10397 }
10398 }
10399 81 }
10400
10401
10402 15539 bool eSpinTile::animate(int32_t index)
10403 {
10404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10405
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10406
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10407 {
10408 1152 return Dead(index);
10409 }
10410
10411
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10412 {
10413 1241 removearmos(x,y,ffcactivated);
10414 1241 }
10415
10416 14387 ++misc;
10417
10418
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10419 {
10420 81 facehero();
10421 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10422 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10423 81 angular=true;
10424 81 angle=ddir;
10425 81 step=zslongToFix(dstep*100);
10426 81 }
10427
10428
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10429 52 kickbucket();
10430
10431 14387 sprite::move(step);
10432 14387 return enemy::animate(index);
10433 15539 }
10434
10435 15457 void eSpinTile::draw(BITMAP *dest)
10436 {
10437 15457 update_enemy_frame();
10438 15457 y-=(misc>>4);
10439 15457 yofs+=2;
10440 15457 enemy::draw(dest);
10441 15457 yofs-=2;
10442 15457 y+=(misc>>4);
10443 15457 }
10444
10445 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10446 {
10447 15457 flip = 0;
10448 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10449 15457 yofs+=4;
10450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10451 15457 enemy::drawshadow(dest, translucent);
10452 15457 yofs-=4;
10453 15457 }
10454
10455 2797 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10456 2797 {
10457 //these are here to bypass compiler warnings about unused arguments
10458 2797 Clk=Clk;
10459 2797 mainguy=false;
10460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2797 times.
2797 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10461
1/4
✓ Branch 0 taken 2797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2797 if (SIZEflags != 0) init_size_flags();;
10462 2797 }
10463
10464 628398 void eZora::facehero()
10465 {
10466
2/2
✓ Branch 0 taken 10785 times.
✓ Branch 1 taken 617613 times.
628398 if(Hero.x-x==0)
10467 {
10468 10785 dir=(Hero.y+8<y)?up:down;
10469 10785 }
10470 else
10471 {
10472 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10473 617613 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10474
10475
4/4
✓ Branch 0 taken 125430 times.
✓ Branch 1 taken 492183 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 78554 times.
617613 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10476 {
10477 78554 dir=l_down;
10478 78554 }
10479
4/4
✓ Branch 0 taken 91951 times.
✓ Branch 1 taken 447108 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 45075 times.
539059 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10480 {
10481 45075 dir=down;
10482 45075 }
10483
4/4
✓ Branch 0 taken 121090 times.
✓ Branch 1 taken 372894 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 74214 times.
493984 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10484 {
10485 74214 dir=r_down;
10486 74214 }
10487
4/4
✓ Branch 0 taken 162238 times.
✓ Branch 1 taken 257532 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 115362 times.
419770 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10488 {
10489 115362 dir=right;
10490 115362 }
10491
4/4
✓ Branch 0 taken 127279 times.
✓ Branch 1 taken 177129 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 80403 times.
304408 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10492 {
10493 80403 dir=r_up;
10494 80403 }
10495
4/4
✓ Branch 0 taken 88819 times.
✓ Branch 1 taken 135186 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 41943 times.
224005 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10496 {
10497 41943 dir=up;
10498 41943 }
10499
4/4
✓ Branch 0 taken 121548 times.
✓ Branch 1 taken 60514 times.
✓ Branch 2 taken 74672 times.
✓ Branch 3 taken 46876 times.
182062 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10500 {
10501 74672 dir=l_up;
10502 74672 }
10503 else
10504 {
10505 107390 dir=left;
10506 }
10507 }
10508 628398 }
10509
10510 857137 bool eZora::animate(int32_t index)
10511 {
10512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 857137 times.
857137 if(switch_hooked) return enemy::animate(index);
10513
2/2
✓ Branch 0 taken 2854 times.
✓ Branch 1 taken 854283 times.
857137 if(dying)
10514 2854 return Dead(index);
10515
10516
2/2
✓ Branch 0 taken 848537 times.
✓ Branch 1 taken 5746 times.
854283 if(clk==0)
10517 {
10518 5746 removearmos(x,y,ffcactivated);
10519 5746 }
10520
10521
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 854248 times.
854283 if(watch)
10522 {
10523 35 clock_zoras.push_back({screen_spawned, id});
10524 35 return true;
10525 }
10526
10527
2/2
✓ Branch 0 taken 225850 times.
✓ Branch 1 taken 628398 times.
854248 if(get_qr(qr_NEWENEMYTILES))
10528 {
10529 628398 facehero();
10530 628398 }
10531
10532
6/6
✓ Branch 0 taken 5232 times.
✓ Branch 1 taken 4993 times.
✓ Branch 2 taken 4190 times.
✓ Branch 3 taken 830374 times.
✓ Branch 4 taken 6482 times.
✓ Branch 5 taken 2977 times.
854248 switch(clk)
10533 {
10534 case 0: // reposition him
10535 {
10536 6482 int32_t t=0;
10537 6482 int32_t pos2=zc_oldrand()%160 + 16;
10538 6482 bool placed=false;
10539
10540
4/4
✓ Branch 0 taken 6417 times.
✓ Branch 1 taken 38529 times.
✓ Branch 2 taken 26366 times.
✓ Branch 3 taken 5746 times.
44946 while(!placed && t<160)
10541 {
10542 26366 rpos_t rpos = POS_TO_RPOS(pos2, screen_spawned);
10543 90460 auto [sx, sy] = COMBOXY_REGION(rpos);
10544 26366 mapscr* s = get_scr(screen_spawned);
10545
10546 79098 int32_t watertype = iswaterex_z3(s->data[pos2], -1, sx, sy, false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10547
5/6
✓ Branch 0 taken 6604 times.
✓ Branch 1 taken 19762 times.
✓ Branch 2 taken 6604 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 400 times.
✓ Branch 5 taken 5681 times.
32447 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10548
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6572 times.
6604 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10549
3/4
✓ Branch 0 taken 6572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6081 times.
✓ Branch 3 taken 6049 times.
6604 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10550 {
10551 5681 x=sx;
10552 5681 y=sy;
10553
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5341 times.
5681 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10554 5681 hxofs=1000; // avoid hit detection
10555 5681 stunclk=0;
10556 5681 placed=true;
10557 5681 }
10558
10559 38464 pos2+=19;
10560
10561
2/2
✓ Branch 0 taken 33901 times.
✓ Branch 1 taken 4563 times.
38464 if(pos2>=176)
10562 4563 pos2-=160;
10563
10564 38464 ++t;
10565 }
10566
10567
3/4
✓ Branch 0 taken 5681 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5681 times.
5746 if(!placed || whistleclk>=88) // can't place him, he's gone
10568 65 return true;
10569
10570 }
10571 5681 break;
10572
10573 case 35:
10574
2/2
✓ Branch 0 taken 3871 times.
✓ Branch 1 taken 1361 times.
5232 if(!get_qr(qr_NEWENEMYTILES))
10575 {
10576 1361 dir=(Hero.y+8<y)?up:down;
10577 1361 }
10578
10579 5232 hxofs=0;
10580 5232 break;
10581
10582 case 35+19:
10583 4993 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10584 4993 sfx(wpnsfx(wpn),pan(int32_t(x)));
10585 4993 break;
10586
10587 case 35+66:
10588 4190 hxofs=1000;
10589 4190 break;
10590
10591 case 198:
10592 2977 clk=-1;
10593 2977 break;
10594 }
10595
10596 853447 return enemy::animate(index);
10597 856401 }
10598
10599 867086 void eZora::draw(BITMAP *dest)
10600 {
10601
2/2
✓ Branch 0 taken 20009 times.
✓ Branch 1 taken 847077 times.
867086 if (isSubmerged())
10602 20009 return;
10603
10604 847077 update_enemy_frame();
10605 847077 enemy::draw(dest);
10606 867086 }
10607
10608 867318 bool eZora::isSubmerged() const
10609 {
10610 867318 return clk < 3;
10611 }
10612
10613
3/6
✓ Branch 0 taken 50248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50248 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50248 times.
✗ Branch 5 not taken.
100496 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10614 50248 {
10615 50248 multishot= timer = fired = dashing = 0;
10616 50248 hashero = false;
10617 50248 dummy_bool[0]=false;
10618
4/8
✓ Branch 0 taken 50248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50248 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50248 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50248 times.
✗ Branch 7 not taken.
50248 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10619
5/6
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 49246 times.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 519 times.
✓ Branch 5 taken 483 times.
50248 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10620 {
10621
2/4
✓ Branch 0 taken 519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 519 times.
✗ Branch 3 not taken.
519 step=zslongToFix(dmisc10*100);
10622
10623
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 501 times.
519 if(anim==aARMOS4) o_tile+=20;
10624 519 }
10625
10626
3/4
✓ Branch 0 taken 50248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1002 times.
✓ Branch 3 taken 49246 times.
50248 if(flags & guy_fade_flicker)
10627 {
10628 1002 clk=0;
10629 1002 superman = 1;
10630 1002 fading=fade_flicker;
10631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1002 times.
1002 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10632 1002 dir=down;
10633
10634
4/6
✓ Branch 0 taken 1002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 561 times.
1002 if(!canmove(down,(zfix)8,spw_none,false))
10635
3/6
✓ Branch 0 taken 441 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 441 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 441 times.
✗ Branch 5 not taken.
441 clk3=int32_t(13.0/step);
10636 1002 }
10637
3/4
✓ Branch 0 taken 49246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49113 times.
✓ Branch 3 taken 133 times.
49246 else if(flags & guy_fade_instant)
10638 {
10639 133 clk=0;
10640 133 }
10641
10642
1/2
✓ Branch 0 taken 50248 times.
✗ Branch 1 not taken.
50248 shadowdistance = 0;
10643 50248 clk4 = clk5 = 0;
10644 //nets+2380;
10645
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50246 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
50248 if (SIZEflags != 0) init_size_flags();;
10646 50248 }
10647
10648 15820237 bool eStalfos::animate(int32_t index)
10649 {
10650
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 15819981 times.
15820237 if(switch_hooked) return enemy::animate(index);
10651
3/4
✓ Branch 0 taken 15819555 times.
✓ Branch 1 taken 426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15819555 times.
15819981 if(fallclk||drownclk)
10652 {
10653 426 return enemy::animate(index);
10654 }
10655
2/2
✓ Branch 0 taken 352934 times.
✓ Branch 1 taken 15466621 times.
15819555 if(dying)
10656 {
10657
2/2
✓ Branch 0 taken 352886 times.
✓ Branch 1 taken 48 times.
352934 if(hashero)
10658 {
10659 48 Hero.setEaten(0);
10660 48 hashero=false;
10661 48 }
10662
10663
10/14
✓ Branch 0 taken 36032 times.
✓ Branch 1 taken 316902 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 32347 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
352934 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10664 {
10665 187 hp=-1000;
10666
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10667 187 Ewpns.add(ew);
10668 187 ew->fakez = fakez;
10669
10670
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10671 {
10672 187 ew->step=0;
10673 187 ew->id=wpn;
10674 187 ew->misc=50;
10675 187 ew->clk=48;
10676 187 }
10677
10678 187 fired=true;
10679 187 }
10680
6/6
✓ Branch 0 taken 156352 times.
✓ Branch 1 taken 196395 times.
✓ Branch 2 taken 130300 times.
✓ Branch 3 taken 26052 times.
✓ Branch 4 taken 130282 times.
✓ Branch 5 taken 18 times.
352747 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10681 {
10682
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10683 {
10684 1 int32_t wpn2 = wpn+dmisc3;
10685
10686
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10687 {
10688 wpn2=wpn;
10689 }
10690
10691 1 dummy_bool[0]=true;
10692 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10693 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10694 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10695 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10696 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10697 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10698 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10699 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10700 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10701 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10702 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10703 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10704 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10705 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10706 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10707 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10708 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
10709 1 }
10710 18 }
10711
10712 352934 KillWeapon();
10713 352934 return Dead(index);
10714 }
10715 //vire split
10716 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10717 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10718
13/14
✓ Branch 0 taken 21138 times.
✓ Branch 1 taken 15445483 times.
✓ Branch 2 taken 21138 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 20787 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14273574 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
15466621 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10719 {
10720 1677 stop_bgsfx(index);
10721 1677 int32_t kids = guys.Count();
10722 1677 int32_t id2=dmisc3;
10723
2/2
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 1677 times.
4984 for(int32_t i=0; i < dmisc4; i++)
10724 {
10725
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2035 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3307 times.
3307 if(addenemy(screen_spawned,x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10726 3307 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10727 3307 }
10728
10729
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1676 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1677 if (itemguy && guys.Count()) // Hand down the carried item
10730 {
10731 1 int guycarryingitem = guys.Count()-1;
10732 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10733 1 itemguy = false;
10734 1 }
10735
10736
2/2
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 17 times.
1677 if(hashero)
10737 {
10738 17 Hero.setEaten(0);
10739 17 hashero=false;
10740 17 }
10741
10742
4/4
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 323 times.
1677 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10743 323 sfx(deadsfx,pan(int32_t(x)));
10744
10745 1677 return true;
10746 }
10747
10748
2/2
✓ Branch 0 taken 71160 times.
✓ Branch 1 taken 15393784 times.
15464944 if(fading)
10749 {
10750
2/2
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 69932 times.
71160 if(++clk4 > 60)
10751 {
10752 1228 clk4=0;
10753 1228 superman=0;
10754 1228 fading=0;
10755
10756
4/6
✓ Branch 0 taken 967 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 967 times.
1228 if(flags&guy_armos && z==0 && fakez == 0)
10757 {
10758 //if a custom size (not 16px by 16px)
10759
10760 //if a custom size (not 16px by 16px)
10761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 967 times.
967 if (ffcactivated)
10762 removearmosffc(*ffcactivated);
10763 else
10764 {
10765
4/8
✓ Branch 0 taken 967 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 967 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 967 times.
967 if (txsz > 1 || tysz > 1 || (SIZEflags&OVERRIDE_HIT_WIDTH) || (SIZEflags&OVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10766 {
10767 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10768 for(int32_t dx = 0; dx < tysz; dx ++)
10769 {
10770 for(int32_t dy = 0; dy < tysz; dy++)
10771 {
10772 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10773 did_armos = false;
10774 }
10775 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10776 did_armos = false;
10777 }
10778 for(int32_t dy = 0; dy < tysz; dy ++)
10779 {
10780 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10781 did_armos = false;
10782 }
10783 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10784 }
10785 967 else removearmos(x,y);
10786 }
10787
10788 967 }
10789
10790 1228 clk2=0;
10791
10792 1228 newdir();
10793 1228 }
10794 69932 else return enemy::animate(index);
10795 1228 }
10796
6/8
✓ Branch 0 taken 148409 times.
✓ Branch 1 taken 15245375 times.
✓ Branch 2 taken 148409 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148409 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 138854 times.
✓ Branch 7 taken 9555 times.
15393784 else if(flags&guy_armos && z==0 && fakez == 0 && clk==0)
10797 9555 removearmos(x,y,ffcactivated);
10798
10799
10800
2/2
✓ Branch 0 taken 7207 times.
✓ Branch 1 taken 15387805 times.
15395012 if(hashero)
10801 {
10802 7207 Hero.setX(x);
10803 7207 Hero.setY(y);
10804 7207 ++clk2;
10805
10806
4/4
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6308 times.
✓ Branch 3 taken 899 times.
7207 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10807 {
10808
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 877 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
899 switch(dmisc7)
10809 {
10810 case e7tEATITEMS:
10811 {
10812
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
10813 {
10814
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&item_edible)
10815 22 game->set_item(i, false);
10816 5632 }
10817
10818 22 break;
10819 }
10820
10821 case e7tEATMAGIC:
10822 game->change_dmagic(-1*game->get_magicdrainrate());
10823 break;
10824
10825 case e7tEATRUPEES:
10826 game->change_drupy(-1);
10827 break;
10828 }
10829
10830 899 clk2=0;
10831 899 }
10832
10833
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6661 times.
7207 if((clk&0x18)==8) // stop its animation on the middle frame
10834 6661 --clk;
10835 7207 }
10836
4/4
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14338932 times.
✓ Branch 2 taken 616037 times.
✓ Branch 3 taken 432836 times.
15387805 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10837 {
10838 // Movement engine
10839
6/6
✓ Branch 0 taken 839292 times.
✓ Branch 1 taken 14115677 times.
✓ Branch 2 taken 3294 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14112216 times.
✓ Branch 5 taken 59 times.
14954969 if(clk>=0) switch(id>>12)
10840 {
10841 case 0: // Normal movement
10842
10843 /*
10844 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10845 {
10846 // Overloading clk4 (Tribble clock) here...
10847 step=17/100.0;
10848 if(clk4<32) misc=1;
10849 else if(clk4<48) misc=2;
10850 else if(clk4<300) { misc=3; step = dstep/100.0; }
10851 else if(clk4<316) misc=2;
10852 else if(clk4<412) misc=1;
10853 else if(clk4<540) { misc=0; step=0; }
10854 else clk4=0;
10855 if(clk4==48) clk=0;
10856 hxofs=(misc>=2)?0:1000;
10857 if (dmisc9==e9tLEEVER)
10858 variable_walk(rate, homing, 0);
10859 else
10860 variable_walk_8(rate, homing, 4, 0);
10861 break;
10862 }
10863 */
10864
4/4
✓ Branch 0 taken 13733182 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13316106 times.
14112216 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10865 {
10866 796110 vire_hop();
10867 796110 break;
10868 }
10869
2/2
✓ Branch 0 taken 984687 times.
✓ Branch 1 taken 12331419 times.
13316106 else if(dmisc9==e9tROPE) //Rope charge
10870 {
10871
9/10
✓ Branch 0 taken 967265 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 138779 times.
✓ Branch 3 taken 828486 times.
✓ Branch 4 taken 126694 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 125869 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 125869 times.
984687 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10872 {
10873
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 116793 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
125869 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10874 {
10875
10876
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10877 {
10878 14 hp=-1000;
10879
10880
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10881 {
10882
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10883 14 Ewpns.add(ew);
10884 14 ew->fakez = fakez;
10885
10886
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10887 {
10888 14 ew->step=0;
10889 14 ew->id=wpn+dmisc3;
10890 14 ew->misc=50;
10891 14 ew->clk=48;
10892 14 }
10893
10894 14 fired=true;
10895 14 }
10896 else
10897 {
10898 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10899 Ewpns.add(ew);
10900 ew->fakez = fakez;
10901
10902 if(wpn==ewSBomb || wpn==ewBomb)
10903 {
10904 ew->step=0;
10905 ew->id=wpn;
10906 ew->misc=50;
10907 ew->clk=48;
10908 }
10909
10910 fired=true;
10911 }
10912 14 }
10913
10914 else
10915 {
10916 33 hp=-1000;
10917
10918 int32_t wpn2;
10919
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10920 33 wpn2=wpn;
10921 else
10922 wpn2=wpn;
10923
10924
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10925 33 Ewpns.add(ew);
10926 33 ew->fakez = fakez;
10927
10928
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10929 {
10930 33 ew->step=0;
10931 33 ew->id=wpn2;
10932 33 ew->misc=50;
10933 33 ew->clk=48;
10934 33 }
10935
10936 33 fired=true;
10937 }
10938 47 }
10939 125869 }
10940
10941 984687 charge_attack();
10942 984687 break;
10943 }
10944 /*
10945 * Boomerang-throwers have a halt count of 1
10946 * Zols have a halt count of (zc_oldrand()&7)<<4
10947 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
10948 * Everything else has 48
10949 */
10950 else
10951 {
10952
2/2
✓ Branch 0 taken 568419 times.
✓ Branch 1 taken 11763000 times.
12331419 if(wpn==ewBrang) // Goriya
10953 {
10954 568419 halting_walk(rate,homing,0,hrate, 1);
10955 568419 }
10956
4/4
✓ Branch 0 taken 11613624 times.
✓ Branch 1 taken 149376 times.
✓ Branch 2 taken 4551928 times.
✓ Branch 3 taken 7061696 times.
11763000 else if(dmisc9==e9tNORMAL && wpn==0)
10957 {
10958
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6343723 times.
7061696 if(dmisc2==e2tSPLITHIT) // Zol
10959 {
10960 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
10961 717973 }
10962
4/4
✓ Branch 0 taken 1754155 times.
✓ Branch 1 taken 4589568 times.
✓ Branch 2 taken 1538264 times.
✓ Branch 3 taken 215891 times.
6343723 else if(frate<=8 && starting_hp==1) // Gel
10963 {
10964 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
10965 215891 }
10966 else // Other
10967 {
10968 6127832 halting_walk(rate,homing,0,hrate, 48);
10969 }
10970 7061696 }
10971 else // Other
10972 {
10973 4701304 halting_walk(rate,homing,0,hrate, 48);
10974 }
10975 }
10976
10977 //if not in midair, and Hero's swinging sword is nearby, jump.
10978 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
10979 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
10980 {
10981 facehero(false);
10982 sclk=16+((dir^1)<<8);
10983 fall=-FEATHERJUMP;
10984 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
10985 }*/
10986 12331419 break;
10987
10988 // Following cases are for just after creation-by-splitting.
10989 case 1:
10990
2/2
✓ Branch 0 taken 2473 times.
✓ Branch 1 taken 821 times.
3294 if(misc==1)
10991 {
10992 821 dir=up;
10993 821 step=8;
10994 821 }
10995
10996
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 2504 times.
3294 if(misc<=2)
10997 {
10998 2504 move(step);
10999
11000
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 512 times.
2504 if(!canmove(dir,(zfix)0,0,false))
11001 512 dir=down;
11002 2504 }
11003
11004
2/2
✓ Branch 0 taken 2504 times.
✓ Branch 1 taken 790 times.
3294 if(misc==3)
11005 {
11006
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 503 times.
790 if(canmove(right,(zfix)16,0,false))
11007 503 x+=16;
11008 790 }
11009
11010 3294 ++misc;
11011 3294 break;
11012
11013 case 2:
11014
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
11015 {
11016 15 dir=down;
11017 15 step=8;
11018 15 }
11019
11020
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
11021 {
11022 45 move(step);
11023 /*
11024 if(!canmove(dir,(zfix)0,0,false))
11025 dir=up;
11026 */
11027 45 }
11028
11029
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
11030 {
11031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
11032 14 x-=16;
11033 14 }
11034
11035 59 ++misc;
11036 59 break;
11037
11038 default:
11039
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11040 {
11041 28 dir=(zc_oldrand()%4);
11042 28 step=8;
11043 28 }
11044
11045
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11046 {
11047 83 move(step);
11048
11049
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11050 2 dir=dir^1;
11051 83 }
11052
11053
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11054 {
11055
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11056 8 x+=(dir==left ? -16 : 16);
11057 25 }
11058
11059 108 ++misc;
11060 108 break;
11061 14115677 }
11062
11063
4/4
✓ Branch 0 taken 25272 times.
✓ Branch 1 taken 14929697 times.
✓ Branch 2 taken 24443 times.
✓ Branch 3 taken 829 times.
14954969 if(id>>12 && misc>=4) //recently spawned by a split enemy
11064 {
11065 829 id&=0xFFF;
11066 829 step = zslongToFix(dstep*100);
11067
11068
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if(x<32) x=32;
11069
11070
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 21 times.
829 if(x>208) x=208;
11071
11072
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 24 times.
829 if(y<32) y=32;
11073
11074
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 7 times.
829 if(y>128) y=128;
11075
11076 829 misc=3;
11077 829 }
11078 14954969 }
11079 else
11080 {
11081 //sfx(wpnsfx(wpn),pan(int32_t(x)));
11082
1/2
✓ Branch 0 taken 432836 times.
✗ Branch 1 not taken.
432836 if(clk2>2) clk2--;
11083 }
11084
11085 // Fire Zol
11086
8/8
✓ Branch 0 taken 6104645 times.
✓ Branch 1 taken 9290367 times.
✓ Branch 2 taken 139281 times.
✓ Branch 3 taken 5965364 times.
✓ Branch 4 taken 1131 times.
✓ Branch 5 taken 138150 times.
✓ Branch 6 taken 1102 times.
✓ Branch 7 taken 29 times.
15395012 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11087 {
11088 1102 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11089 1102 sfx(wpnsfx(wpn),pan(int32_t(x)));
11090
11091 1102 int32_t i=Ewpns.Count()-1;
11092 1102 weapon *ew = (weapon*)(Ewpns.spr(i));
11093
11094
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1102 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11095 {
11096 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11097 if ( ew->do_animation ) ew->tile+=ew->aframe;
11098 }
11099 1102 }
11100 // Goriya
11101
14/16
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14345037 times.
✓ Branch 2 taken 468534 times.
✓ Branch 3 taken 580339 times.
✓ Branch 4 taken 456235 times.
✓ Branch 5 taken 12299 times.
✓ Branch 6 taken 423258 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 423258 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 420517 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 420517 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 414155 times.
✓ Branch 15 taken 6362 times.
15393910 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11102 {
11103 6362 misc=index+100;
11104
7/14
✓ Branch 0 taken 6362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6362 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6362 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6362 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6362 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6362 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6362 times.
✗ Branch 13 not taken.
6362 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11105 6362 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11106
11107
2/2
✓ Branch 0 taken 6105 times.
✓ Branch 1 taken 257 times.
6362 if(dmisc1==2)
11108 {
11109 257 int32_t ndir=dir;
11110
11111
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11112 {
11113 6 ndir=(Hero.y+8<y)?up:down;
11114 6 }
11115 else //turn to face Hero
11116 {
11117 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11118 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11119
11120
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11121 {
11122 13 ndir=down;
11123 13 }
11124
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11125 {
11126 68 ndir=right;
11127 68 }
11128
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11129 {
11130 48 ndir=up;
11131 48 }
11132 else
11133 {
11134 122 ndir=left;
11135 }
11136 }
11137
11138 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11139
11140
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11141 {
11142 223 dir=ndir;
11143 223 }
11144 257 }
11145 6362 }
11146
15/16
✓ Branch 0 taken 15328662 times.
✓ Branch 1 taken 58886 times.
✓ Branch 2 taken 221198 times.
✓ Branch 3 taken 15166350 times.
✓ Branch 4 taken 195080 times.
✓ Branch 5 taken 26118 times.
✓ Branch 6 taken 170188 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 168804 times.
✓ Branch 9 taken 1384 times.
✓ Branch 10 taken 153704 times.
✓ Branch 11 taken 15100 times.
✓ Branch 12 taken 153704 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 152760 times.
15387548 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11147
3/3
✓ Branch 0 taken 26122 times.
✓ Branch 1 taken 125732 times.
✓ Branch 2 taken 906 times.
152760 switch(dmisc1)
11148 {
11149 case e1tCONSTANT: //Deathnut
11150 {
11151 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11152
2/2
✓ Branch 0 taken 123149 times.
✓ Branch 1 taken 2583 times.
125732 if(clk5>64)
11153 {
11154 2583 clk5=0;
11155 2583 fired=false;
11156 2583 }
11157
11158 125732 clk5+=(zc_oldrand()&3);
11159
11160
4/4
✓ Branch 0 taken 76714 times.
✓ Branch 1 taken 49018 times.
✓ Branch 2 taken 25645 times.
✓ Branch 3 taken 51069 times.
125732 if((clk5>24)&&(clk5<52))
11161 {
11162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51069 times.
51069 if ( do_animation )tile+=20; //firing
11163
11164
4/4
✓ Branch 0 taken 27958 times.
✓ Branch 1 taken 23111 times.
✓ Branch 2 taken 25131 times.
✓ Branch 3 taken 2827 times.
51069 if(!fired&&(clk5>=38))
11165 {
11166
5/10
✓ Branch 0 taken 2827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2827 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2827 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2827 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2827 times.
✗ Branch 9 not taken.
2827 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11167 2827 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11168 2827 sfx(wpnsfx(wpn),pan(int32_t(x)));
11169 2827 fired=true;
11170 2827 }
11171 51069 }
11172
11173 125732 break;
11174 }
11175
11176 case e1tFIREOCTO: //Fire Octo
11177 906 timer=zc_oldrand()%50+50;
11178 906 break;
11179
11180 default:
11181 26122 FireWeapon();
11182 26122 break;
11183 152760 }
11184
11185 /* Fire again if:
11186 * - clk2 about to run out
11187 * - not already double-firing (dmisc1 is 1)
11188 * - not carrying Hero
11189 * - one in 0xF chance
11190 */
11191
8/10
✓ Branch 0 taken 524938 times.
✓ Branch 1 taken 14870074 times.
✓ Branch 2 taken 4002 times.
✓ Branch 3 taken 520936 times.
✓ Branch 4 taken 4002 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4002 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3751 times.
✓ Branch 9 taken 251 times.
15395012 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11192 {
11193 #if 1
11194 251 newdir(rate, homing, grumble);
11195 #else
11196 dir^=2;
11197 #endif
11198 251 clk2=28;
11199 251 ++multishot;
11200 251 }
11201
11202
2/2
✓ Branch 0 taken 3492669 times.
✓ Branch 1 taken 11902343 times.
15395012 if(clk2==0)
11203 {
11204 11902343 multishot = 0;
11205 11902343 }
11206
11207
2/2
✓ Branch 0 taken 15330702 times.
✓ Branch 1 taken 64310 times.
15395012 if(timer) //Fire Octo
11208 {
11209 64310 clk2=15; //this keeps the octo in place until he's done firing
11210
11211
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11212 {
11213 15752 FireBreath(false);
11214 15752 }
11215
11216 64310 --timer;
11217 64310 }
11218
11219
2/2
✓ Branch 0 taken 15145619 times.
✓ Branch 1 taken 249393 times.
15395012 if(dmisc2==e2tTRIBBLE)
11220 249393 ++clk4;
11221
11222
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15390532 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15394319 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15395012 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11223 {
11224 693 int32_t kids = guys.Count();
11225 693 int32_t id2=dmisc3;
11226
11227
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11228 {
11229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(screen_spawned,x,y,id2,-24))
11230 {
11231
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11232 {
11233 int guycarryingitem = guys.Count()-1;
11234 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11235 itemguy = false;
11236 }
11237
11238 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11239 693 }
11240 693 }
11241
11242
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11243 {
11244 Hero.setEaten(0);
11245 hashero=false;
11246 }
11247
11248 693 stop_bgsfx(index);
11249 693 return true;
11250 }
11251
11252 15394319 return enemy::animate(index);
11253 15820237 }
11254
11255 16242526 void eStalfos::draw(BITMAP *dest)
11256 {
11257 16242526 update_enemy_frame();
11258
11259
7/8
✓ Branch 0 taken 16242100 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 16242100 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86951 times.
✓ Branch 5 taken 16155149 times.
✓ Branch 6 taken 75836 times.
✓ Branch 7 taken 11115 times.
16242526 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11260 {
11261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11262 11115 }
11263
11264 16242526 enemy::draw(dest);
11265 16242526 }
11266
11267 7536221 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11268 {
11269 7536221 int32_t tempy=yofs;
11270
11271
4/4
✓ Branch 0 taken 7320803 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7224602 times.
✓ Branch 3 taken 311619 times.
7536221 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11272 {
11273 311619 flip = 0;
11274 311619 int32_t fdiv = frate/4;
11275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11276
11277
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11278 311619 efrate:((clk>=(frate>>1))?1:0);
11279 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11280
11281
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11282 {
11283 311619 shadowtile+=f2;
11284 311619 }
11285 else
11286 {
11287 shadowtile+=f2?1:0;
11288 }
11289
11290 311619 yofs+=shadowdistance;
11291 311619 yofs+=8;
11292 311619 }
11293
4/4
✓ Branch 0 taken 7320803 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7533186 times.
✓ Branch 3 taken 3035 times.
7536221 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11294 {
11295 3035 flip = 0;
11296 3035 int32_t fdiv = frate/4;
11297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11298
11299
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11300 3035 efrate:((clk>=(frate>>1))?1:0);
11301 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11302
11303
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11304 {
11305 3035 shadowtile+=f2;
11306 3035 }
11307 else
11308 {
11309 shadowtile+=f2?1:0;
11310 }
11311 3035 }
11312
2/2
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 7530725 times.
7536221 if(!shadow_overpit(this))
11313 7530725 enemy::drawshadow(dest, translucent);
11314 7536221 yofs=tempy;
11315 7536221 }
11316
11317 157762 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11318 {
11319 157762 int32_t wpnId = w->id;
11320 157762 int32_t wpnDir = w->dir;
11321
11322
4/4
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 156344 times.
✓ Branch 2 taken 609 times.
✓ Branch 3 taken 809 times.
157762 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11323
6/8
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 385 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265 times.
✓ Branch 5 taken 120 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 120 times.
609 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11324
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
120 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11325 {
11326 265 shield = false;
11327 265 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11328
11329
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 243 times.
265 if(get_qr(qr_BRKNSHLDTILES))
11330 243 o_tile=s_tile;
11331 265 }
11332
11333 157762 int32_t ret = enemy::takehit(w,realweap);
11334
11335
4/4
✓ Branch 0 taken 22325 times.
✓ Branch 1 taken 135437 times.
✓ Branch 2 taken 20574 times.
✓ Branch 3 taken 1751 times.
157762 if(sclk && dmisc2==e2tSPLITHIT)
11336 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11337
11338 157762 return ret;
11339 }
11340
11341 984687 void eStalfos::charge_attack()
11342 {
11343
2/2
✓ Branch 0 taken 6715 times.
✓ Branch 1 taken 977972 times.
984687 if(slide())
11344 6715 return;
11345
11346
10/12
✓ Branch 0 taken 977972 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 975568 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 946055 times.
✓ Branch 5 taken 29513 times.
✓ Branch 6 taken 924502 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 918879 times.
✓ Branch 9 taken 5623 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 918879 times.
977972 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11347 59093 return;
11348
11349
2/2
✓ Branch 0 taken 37515 times.
✓ Branch 1 taken 881364 times.
918879 if(clk3<=0)
11350 {
11351 37515 fix_coords(true);
11352
11353
2/2
✓ Branch 0 taken 10043 times.
✓ Branch 1 taken 27472 times.
37515 if(!dashing)
11354 {
11355 27472 int32_t ldir = lined_up(7,false);
11356
11357
4/4
✓ Branch 0 taken 3107 times.
✓ Branch 1 taken 24365 times.
✓ Branch 2 taken 456 times.
✓ Branch 3 taken 2651 times.
27472 if(ldir!=-1 && canmove(ldir,false))
11358 {
11359 2651 dir=ldir;
11360 2651 dashing=true;
11361
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2651 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2651 if(dmisc10<=0 || replay_version_check(0,33))
11362 2651 step=zslongToFix(dstep*100)+1;
11363 else
11364 step=zslongToFix(dmisc10*100);
11365 2651 }
11366 24821 else newdir(4,0,0);
11367 27472 }
11368
11369
2/2
✓ Branch 0 taken 36061 times.
✓ Branch 1 taken 1454 times.
37515 if(!canmove(dir,false))
11370 {
11371 1454 step=zslongToFix(dstep*100);
11372 1454 newdir();
11373 1454 dashing=false;
11374 1454 }
11375
11376 37515 zfix div = step;
11377
11378
1/2
✓ Branch 0 taken 37515 times.
✗ Branch 1 not taken.
37515 if(div == 0)
11379 div = 1;
11380
11381 37515 clk3=(int32_t)(16.0/div);
11382 37515 return;
11383 }
11384
11385 881364 move(step);
11386 881364 --clk3;
11387 984687 }
11388
11389 796110 void eStalfos::vire_hop()
11390 {
11391 //if ( sclk > 0 ) return; //Don't hop during knockback.
11392
11393 // if(dmisc9!=e9tPOLSVOICE)
11394 // {
11395 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11396 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11397 // return; //the enemy should split if it is sliding!
11398 // //else sclk=0; //might need this here, too. -Z
11399 // }
11400
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11401 {
11402
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11403 {
11404
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11405 //return;
11406 3843 }
11407 376292 }
11408 417076 else sclk=0;
11409
11410
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11411 31892 return;
11412
11413 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11414 int32_t jump_height;
11415
11416
1/2
✓ Branch 0 taken 761476 times.
✗ Branch 1 not taken.
761476 if ((dmisc10 <= 0))
11417 761476 jump_height = (dmisc9 == e9tPOLSVOICE) ? 27 : 16;
11418 else jump_height = dmisc10;
11419
11420 761476 y=floor_y;
11421
11422
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11423 {
11424 26258 fix_coords();
11425
11426 //z=0;
11427 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11428 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11429
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11430 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11431
11432
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11433 {
11434 //z=0;
11435
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11436 {
11437
11438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11439 /*if (dmisc9==e9tPOLSVOICE )
11440 {
11441 zprint2("polsvoice jump_width is: %d\n", jump_width);
11442 zprint2("polsvoice raw step is: %d\n", step);
11443 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
11444 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
11445 }
11446 else
11447 {
11448 zprint2("vire jump_width is: %d\n", jump_width);
11449 zprint2("vire raw step is: %d\n", step);
11450 zprint2("vire step.getInt() is: %d\n", step.getInt());
11451 zprint2("setting clk2 on vire to: %d\n", clk2);
11452 }
11453 */
11454 17258 }
11455 21336 }
11456
11457
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11458 {
11459 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11460 7030 }
11461
11462 26258 clk3=int32_t(16.0/step.getFloat());
11463 26258 }
11464
11465 761476 --clk3;
11466
11467
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11468 761476 move(step);
11469
11470 761476 floor_y=y;
11471 761476 clk2--;
11472
11473 //if we're in the middle of a jump
11474
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11475 {
11476 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11477
11478
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11479 {
11480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11481 93147 else z=h;
11482 93147 }
11483 else
11484 {
11485 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
11486 //y-=h;
11487 384731 y=floor_y-h;
11488 384731 shadowdistance=h;
11489 }
11490 477878 }
11491 else
11492 283598 shadowdistance = 0;
11493 796110 }
11494
11495 138 void eStalfos::eathero()
11496 {
11497
5/8
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70 times.
138 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11498 {
11499 70 hashero=true;
11500 70 y=floor_y;
11501 70 z=0;
11502
11503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(Hero.isSwimming())
11504 {
11505 Hero.setX(x);
11506 Hero.setY(y);
11507 }
11508 else
11509 {
11510 70 x=Hero.getX();
11511 70 y=Hero.getY();
11512 }
11513
11514 70 clk2=0;
11515 70 }
11516 138 }
11517
11518 1469390 bool eStalfos::WeaponOut()
11519 {
11520
2/2
✓ Branch 0 taken 2400579 times.
✓ Branch 1 taken 622399 times.
3022978 for(int32_t i=0; i<Ewpns.Count(); i++)
11521 {
11522
3/4
✓ Branch 0 taken 846991 times.
✓ Branch 1 taken 1553588 times.
✓ Branch 2 taken 846991 times.
✗ Branch 3 not taken.
2400579 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11523 {
11524 846991 return true;
11525 }
11526 1553588 }
11527
11528 622399 return false;
11529 1469390 }
11530
11531 352934 void eStalfos::KillWeapon()
11532 {
11533
2/2
✓ Branch 0 taken 293384 times.
✓ Branch 1 taken 352934 times.
646318 for(int32_t i=0; i<Ewpns.Count(); i++)
11534 {
11535
4/4
✓ Branch 0 taken 245286 times.
✓ Branch 1 taken 48098 times.
✓ Branch 2 taken 244476 times.
✓ Branch 3 taken 810 times.
293384 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
11536 {
11537 //only kill this Goriya's boomerang -DD
11538
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 411 times.
810 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11539 {
11540 411 Ewpns.del(i);
11541 411 }
11542 810 }
11543 293384 }
11544 352934 }
11545
11546 void eStalfos::break_shield()
11547 {
11548 if(!shield)
11549 return;
11550
11551 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11552 shield=false;
11553
11554 if(get_qr(qr_BRKNSHLDTILES))
11555 o_tile=s_tile;
11556 }
11557
11558 void eStalfos::repair_shield()
11559 {
11560 if (shield)
11561 return;
11562
11563 shield = true;
11564
11565 if (get_qr(qr_BRKNSHLDTILES))
11566 {
11567 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
11568 else o_tile = d->tile;
11569 }
11570 }
11571
11572 13720 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11573 13720 {
11574
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 dir=(zc_oldrand()&7)+8;
11575
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 step=0;
11576 13720 movestatus=1;
11577
3/4
✓ Branch 0 taken 10596 times.
✓ Branch 1 taken 3124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10596 times.
13720 if (dmisc1 != 1 && dmisc19 > 0)
11578 {
11579 step = dmisc19/100.0;
11580 movestatus = 1;
11581 }
11582
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if (dmisc1 == 2) movestatus=2;
11583 13720 c=0;
11584 13720 clk4=0;
11585 //nets;
11586
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 init_size_flags();
11587 13720 dummy_int[1]=0;
11588 13720 }
11589
11590 3535341 bool eKeese::animate(int32_t index)
11591 {
11592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3535341 times.
3535341 if(switch_hooked) return enemy::animate(index);
11593
2/4
✓ Branch 0 taken 3535341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3535341 times.
3535341 if(fallclk||drownclk) return enemy::animate(index);
11594
2/2
✓ Branch 0 taken 124509 times.
✓ Branch 1 taken 3410832 times.
3535341 if(dying)
11595 124509 return Dead(index);
11596
11597
2/2
✓ Branch 0 taken 3384641 times.
✓ Branch 1 taken 26191 times.
3410832 if(clk==0)
11598 {
11599 26191 removearmos(x,y,ffcactivated);
11600 26191 }
11601
11602
2/2
✓ Branch 0 taken 1025042 times.
✓ Branch 1 taken 2385790 times.
3410832 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11603 {
11604 1025042 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11605 1025042 }
11606 else
11607 {
11608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2385790 times.
2385790 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11609 2385790 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11610 }
11611
11612
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3290494 times.
3410832 if(dmisc2 == e2tKEESETRIB)
11613 {
11614
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11615 {
11616
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11617 {
11618 105 int32_t kids = guys.Count();
11619 105 bool success = false;
11620 105 int32_t id2=dmisc3;
11621 105 success = 0 != addenemy(screen_spawned,(zfix)x,(zfix)y,id2,-24);
11622
11623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11624 {
11625
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11626 {
11627 int guycarryingitem = guys.Count()-1;
11628 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11629 itemguy = false;
11630 }
11631
11632 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11633 105 }
11634
11635 105 stop_bgsfx(index);
11636 105 return true;
11637 }
11638 else
11639 {
11640 86 clk4=0;
11641 }
11642 86 }
11643 120233 }
11644 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11645
3/4
✓ Branch 0 taken 845879 times.
✓ Branch 1 taken 2444615 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 845879 times.
3290494 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11646 {
11647
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 158811 times.
845879 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11648 {
11649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11650 {
11651 fakez=int32_t(step/zslongToFix(dstep*100));
11652 // Some variance in keese flight heights when away from Hero
11653 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11654
11655 }
11656 else
11657 {
11658 687068 z=int32_t(step/zslongToFix(dstep*100));
11659 // Some variance in keese flight heights when away from Hero
11660
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11661 }
11662 687068 }
11663 else
11664 {
11665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158811 times.
158811 if (moveflags & move_use_fake_z)
11666 {
11667 fakez=int32_t(step/zslongToFix(dstep*100));
11668 // Some variance in keese flight heights when away from Hero
11669 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11670
11671 }
11672 else
11673 {
11674 158811 z=int32_t(step/zslongToFix(dstep*100));
11675 // Some variance in keese flight heights when away from Hero
11676
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11677 }
11678 }
11679 845879 }
11680
11681 3410727 return enemy::animate(index);
11682 3535341 }
11683
11684 2088281 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11685 {
11686 2088281 int32_t tempy=yofs;
11687 2088281 flip = 0;
11688 2088281 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11689
11690
2/2
✓ Branch 0 taken 667695 times.
✓ Branch 1 taken 1420586 times.
2088281 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11691
2/2
✓ Branch 0 taken 690563 times.
✓ Branch 1 taken 1397718 times.
2088281 if(!get_qr(qr_ENEMIESZAXIS))
11692 {
11693 1397718 yofs+=int32_t(step/zslongToFix(dstep*10));
11694 1397718 }
11695
11696
6/6
✓ Branch 0 taken 2067591 times.
✓ Branch 1 taken 20690 times.
✓ Branch 2 taken 676820 times.
✓ Branch 3 taken 1390771 times.
✓ Branch 4 taken 661452 times.
✓ Branch 5 taken 15368 times.
2088281 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
11697 2052223 enemy::drawshadow(dest, translucent);
11698 2088281 yofs=tempy;
11699 2088281 }
11700
11701 7949863 void eKeese::draw(BITMAP *dest)
11702 {
11703 7949863 update_enemy_frame();
11704 7949863 enemy::draw(dest);
11705 7949863 }
11706
11707 13720 void eKeese::init_size_flags()
11708 {
11709 13720 SIZEflags = d->SIZEflags;
11710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11711
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11712
11713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_WIDTH)) hit_width = 12;
11714
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11715
11716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11717
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11718
11719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_HEIGHT)) hit_height = 8;
11720
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11721
11722
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13720 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11723 // al_trace("Enemy txsz:%i\n", txsz);
11724
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13720 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11725
11726
11727
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11728
11729
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11730
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
11731 {
11732 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11733 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11734 }
11735
11736
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11737 13720 }
11738
11739 20171 void eWizzrobe::submerge(bool set)
11740 {
11741
2/2
✓ Branch 0 taken 20024 times.
✓ Branch 1 taken 147 times.
20171 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11742 {
11743 20024 hxofs = set?1000:0;
11744 20024 return;
11745 }
11746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11747 147 submerged = set;
11748
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11749 76 hxofs+=1000;
11750 71 else hxofs -= 1000;
11751 20171 }
11752 5350 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11753 5350 {
11754 5350 hxofs = 0;
11755 5350 submerged = false;
11756
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 switch(dmisc1)
11757 {
11758 case 0:
11759 2992 submerge(true);
11760 2992 fading=fade_invisible;
11761 // Set clk to just before the 'reappear' threshold
11762
9/10
✓ Branch 0 taken 2991 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2991 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1808 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1807 times.
✓ Branch 9 taken 1 times.
2992 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11763 2992 break;
11764
11765 default:
11766 2358 dir=(loadside==right)?right:left;
11767 2358 misc=-3;
11768 2358 break;
11769 }
11770
11771 //netst+2880;
11772 5350 charging=false;
11773 5350 firing=false;
11774 5350 fclk=0;
11775
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11776
1/4
✓ Branch 0 taken 5350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5350 if (SIZEflags != 0) init_size_flags();;
11777 5350 }
11778
11779 2081613 bool eWizzrobe::animate(int32_t index)
11780 {
11781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2081613 times.
2081613 if(switch_hooked) return enemy::animate(index);
11782
2/4
✓ Branch 0 taken 2081613 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2081613 times.
2081613 if(fallclk||drownclk) return enemy::animate(index);
11783
2/2
✓ Branch 0 taken 38023 times.
✓ Branch 1 taken 2043590 times.
2081613 if(dying)
11784 {
11785 38023 return Dead(index);
11786 }
11787
11788
2/2
✓ Branch 0 taken 1976944 times.
✓ Branch 1 taken 66646 times.
2043590 if(clk==0)
11789 {
11790 66646 removearmos(x,y,ffcactivated);
11791 66646 }
11792
11793
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1024370 times.
2043590 if(dmisc1) // Floating
11794 {
11795 1019220 wizzrobe_attack();
11796 1019220 }
11797 else // Teleporting
11798 {
11799
5/6
✓ Branch 0 taken 1017286 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1006199 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1024370 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11800 {
11801 7084 fading=0;
11802 7084 submerge(false);
11803 7084 solid_update(false);
11804 7084 }
11805
8/8
✓ Branch 0 taken 983365 times.
✓ Branch 1 taken 6240 times.
✓ Branch 2 taken 5313 times.
✓ Branch 3 taken 5151 times.
✓ Branch 4 taken 5006 times.
✓ Branch 5 taken 4247 times.
✓ Branch 6 taken 4109 times.
✓ Branch 7 taken 3855 times.
1017286 else switch(clk)
11806 {
11807 case 0:
11808
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5123 times.
6240 if(!dmisc2)
11809 {
11810 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11811 // but should not appear on dungeon walls.
11812
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4710 times.
5123 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11813
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4486 times.
4710 else if (editorflags&ENEMY_FLAG5)
11814 {
11815 //2.10 Windrobe
11816 //randomise location and face Hero
11817 224 int32_t t=0;
11818 224 bool placed=false;
11819
11820
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11821 {
11822
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon(screen_spawned))
11823 {
11824 280 x=((zc_oldrand()%12)+2)*16;
11825 280 y=((zc_oldrand()%7)+2)*16;
11826 280 }
11827 else
11828 {
11829 87 x=((zc_oldrand()%14)+1)*16;
11830 87 y=((zc_oldrand()%9)+1)*16;
11831 }
11832
11833 367 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11834
11835
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11836 {
11837 224 placed=true;
11838 224 }
11839
11840 367 ++t;
11841 }
11842
11843
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11844 {
11845
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11846 {
11847 47 dir=down;
11848 47 }
11849 else
11850 {
11851 14 dir=up;
11852 }
11853 61 }
11854 else
11855 {
11856
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11857 {
11858 72 dir=right;
11859 72 }
11860 else
11861 {
11862 91 dir=left;
11863 }
11864 }
11865
11866
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11867 return true;
11868
11869
11870 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11871 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11872 224 }
11873 4486 else place_on_axis(true, dmisc4!=0);
11874 5123 }
11875 else
11876 {
11877 1117 int32_t t=0;
11878 1117 bool placed=false;
11879
11880
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11881 {
11882
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon(screen_spawned))
11883 {
11884 1340 x=((zc_oldrand()%12)+2)*16;
11885 1340 y=((zc_oldrand()%7)+2)*16;
11886 1340 }
11887 else
11888 {
11889 1103 x=((zc_oldrand()%14)+1)*16;
11890 1103 y=((zc_oldrand()%9)+1)*16;
11891 }
11892
11893 2443 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11894
11895
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11896 {
11897 1117 placed=true;
11898 1117 }
11899
11900 2443 ++t;
11901 }
11902
11903
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11904 {
11905
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11906 {
11907 238 dir=down;
11908 238 }
11909 else
11910 {
11911 148 dir=up;
11912 }
11913 386 }
11914 else
11915 {
11916
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11917 {
11918 340 dir=right;
11919 340 }
11920 else
11921 {
11922 391 dir=left;
11923 }
11924 }
11925
11926
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
11927 return true;
11928 }
11929
11930 6240 fading=fade_flicker;
11931 6240 submerge(false);
11932 6240 solid_update(false);
11933 6240 break;
11934
11935 case 64:
11936 5313 fading=0;
11937 5313 charging=true;
11938 5313 break;
11939
11940 case 73:
11941 5151 charging=false;
11942 5151 firing=40;
11943 5151 break;
11944
11945 case 83:
11946 5006 wizzrobe_attack_for_real();
11947 5006 break;
11948
11949 case 119:
11950 4247 firing=false;
11951 4247 charging=true;
11952 4247 break;
11953
11954 case 128:
11955 4109 fading=fade_flicker;
11956 4109 charging=false;
11957 4109 break;
11958
11959 case 146:
11960 3855 fading=fade_invisible;
11961 3855 submerge(true);
11962 3855 solid_update(false);
11963
11964 [[fallthrough]];
11965 default:
11966
4/4
✓ Branch 0 taken 987060 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 980971 times.
✓ Branch 3 taken 6249 times.
987220 if(clk>=(146+zc_max(0,dmisc5)))
11967 6249 clk=-1;
11968
11969 987220 break;
11970 }
11971 }
11972
11973 2043590 return enemy::animate(index);
11974 2081613 }
11975
11976 7929 void eWizzrobe::wizzrobe_attack_for_real()
11977 {
11978
1/2
✓ Branch 0 taken 7929 times.
✗ Branch 1 not taken.
7929 if(wpn==0) // Edited enemies
11979 return;
11980
11981
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5946 times.
7929 if(dmisc2 == 0) //normal weapon
11982 {
11983 5946 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
11984 5946 sfx(firesfx, pan(int32_t(x)));
11985 5946 }
11986
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
11987 {
11988 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
11989 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11990 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
11991 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11992 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
11993 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11994 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
11995 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11996 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
11997 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11998 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
11999 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12000 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
12001 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12002 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
12003 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12004 //this block of code was buggy and flat out doesn't match the default wpnsfx for these weapons.
12005 //i've compromised by making all old quest use this code chunk by default.
12006
1/2
✓ Branch 0 taken 995 times.
✗ Branch 1 not taken.
995 if (FFCore.quest_format[vGuys] < 51)
12007 {
12008 995 sfx(WAV_FIRE, pan(int32_t(x)));
12009
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) sfx(WAV_FIRE,pan(int32_t(x)));
12010 else
12011 {
12012
3/17
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
507 switch (wpn)
12013 {
12014 19 case ewFireball: sfx(40, pan(int32_t(x))); break;
12015 case ewBrang: sfx(4, pan(int32_t(x))); break; //Ghost.zh has 0?
12016 case ewSword: sfx(20, pan(int32_t(x))); break; //Ghost.zh has 0?
12017 case ewRock: sfx(51, pan(int32_t(x))); break;
12018 68 case ewMagic: sfx(32, pan(int32_t(x))); break;
12019 case ewBomb: sfx(3, pan(int32_t(x))); break; //Ghost.zh has 0?
12020 case ewSBomb: sfx(3, pan(int32_t(x))); break; //Ghost.zh has 0?
12021 case ewLitBomb: sfx(21, pan(int32_t(x))); break; //Ghost.zh has 0?
12022 case ewLitSBomb: sfx(21, pan(int32_t(x))); break; //Ghost.zh has 0?
12023 case ewFireTrail: sfx(13, pan(int32_t(x))); break;
12024 420 case ewFlame: sfx(13, pan(int32_t(x))); break;
12025 case ewWind: sfx(32, pan(int32_t(x))); break;
12026 case ewFlame2: sfx(13, pan(int32_t(x))); break;
12027 case ewFlame2Trail: sfx(13, pan(int32_t(x))); break;
12028 case ewIce: sfx(44, pan(int32_t(x))); break;
12029 case ewFireball2: sfx(40, pan(int32_t(x))); break; //fireball (rising)
12030 default: sfx(WAV_FIRE, pan(int32_t(x))); break;
12031 }
12032 }
12033 995 }
12034 else
12035 {
12036 sfx(firesfx, pan(int32_t(x)));
12037 }
12038 995 }
12039
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
12040 {
12041 971 int32_t bc=0;
12042
12043
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
12044 {
12045
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12046 {
12047 5195 ++bc;
12048 5195 }
12049 10497 }
12050
12051
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
12052 {
12053 963 int32_t kids = guys.Count();
12054 963 int32_t bats=(zc_oldrand()%3)+1;
12055
12056
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
12057 {
12058 // Summon bats (or anything)
12059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(screen_spawned, x,y,dmisc3,-10, this->getUID()))
12060 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12061 1965 }
12062 963 sfx(firesfx, pan(int32_t(x)));
12063 963 }
12064 971 }
12065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12066 {
12067
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies(screen_spawned)==0)
12068 {
12069 return;
12070 }
12071
12072 17 int32_t kids = guys.Count();
12073
12074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12075 {
12076 17 int32_t newguys=(zc_oldrand()%3)+1;
12077 17 bool summoned=false;
12078
12079
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12080 {
12081 32 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
12082 32 int32_t x2=0;
12083 32 int32_t y2=0;
12084
12085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12086 {
12087 36 x2=16*((zc_oldrand()%12)+2);
12088 36 y2=16*((zc_oldrand()%7)+2);
12089
12090
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12091 {
12092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->getUID()))
12093 {
12094 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12095
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
12096 {
12097 ((enemy*)guys.spr(kids+i))->fakez = 64;
12098 ((enemy*)guys.spr(kids+i))->z = 0;
12099 }
12100 32 }
12101
12102 32 summoned=true;
12103 32 break;
12104 }
12105 4 }
12106 32 }
12107
12108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12109 {
12110 17 sfx(firesfx, pan(int32_t(x)));
12111 17 }
12112 17 }
12113 17 }
12114 7929 }
12115
12116
12117 1019220 void eWizzrobe::wizzrobe_attack()
12118 {
12119
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12120 86341 return;
12121
12122
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12123 {
12124 39538 fix_coords();
12125
12126
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12127 {
12128 case 1: //walking
12129
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12130 2644 misc=0;
12131 else
12132 {
12133 10364 clk3=16;
12134
12135
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12136 {
12137 1398 wizzrobe_newdir(0);
12138 1398 }
12139 }
12140
12141 13008 break;
12142
12143 case 2: //phasing
12144 {
12145 3903 int32_t jx=x;
12146 3903 int32_t jy=y;
12147 3903 int32_t jdir=-1;
12148
12149
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12150 {
12151 case 0:
12152 484 jx-=32;
12153 484 jy-=32;
12154 484 jdir=15;
12155 484 break;
12156
12157 case 1:
12158 472 jx+=32;
12159 472 jy-=32;
12160 472 jdir=9;
12161 472 break;
12162
12163 case 2:
12164 482 jx+=32;
12165 482 jy+=32;
12166 482 jdir=11;
12167 482 break;
12168
12169 case 3:
12170 492 jx-=32;
12171 492 jy+=32;
12172 492 jdir=13;
12173 492 break;
12174 }
12175
12176
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12177 {
12178 1140 misc=3;
12179 1140 clk3=32;
12180 1140 dir=jdir;
12181 1140 break;
12182 }
12183 2763 }
12184 [[fallthrough]];
12185 case 3:
12186 3813 dir&=3;
12187 3813 misc=0;
12188 [[fallthrough]];
12189 case 0:
12190 19894 wizzrobe_newdir(64);
12191 [[fallthrough]];
12192 default:
12193
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12194 {
12195
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12196 {
12197 3265 misc=1;
12198 3265 clk3=16;
12199 3265 }
12200 else
12201 {
12202 239 wizzrobe_newdir(64);
12203 239 misc=0;
12204 239 clk3=32;
12205 }
12206 3504 }
12207 else
12208 {
12209 21886 clk3=32;
12210 }
12211
12212 25390 break;
12213 }
12214
12215
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12216 4478 ++misc;
12217 39538 }
12218
12219 932879 --clk3;
12220
12221
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12222 {
12223 case 1:
12224 case 3:
12225 248377 step=1;
12226 248377 break;
12227
12228 case 2:
12229 63903 step=0;
12230 63903 break;
12231
12232 default:
12233 620599 step=0.5;
12234 620599 break;
12235
12236 }
12237
12238 932879 move(step);
12239
12240 // if(d->misc1 && misc<=0 && clk3==28)
12241
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12242 {
12243
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12244 {
12245
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12246 {
12247 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12248 // sfx(WAV_WAND,pan(int32_t(x)));
12249 1928 wizzrobe_attack_for_real();
12250 1928 fclk=30;
12251 1928 }
12252 16835 }
12253 else
12254 {
12255
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12256 {
12257 995 wizzrobe_attack_for_real();
12258 995 fclk=30;
12259 995 }
12260 }
12261 21547 }
12262
12263
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12264 4050 misc=2;
12265
12266
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12267 3441 fix_coords();
12268
12269
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12270 {
12271
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12272 {
12273 83282 --fclk;
12274 83282 }
12275 932879 }
12276
12277 1019220 }
12278
12279 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12280 {
12281 // Wizzrobes shouldn't move to the edge of the screen;
12282 // if they're already there, they should move toward the center
12283
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12284 33 dir=right;
12285
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=world_w-32)
12286 4 dir=left;
12287
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12288 2 dir=down;
12289
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=world_h-32)
12290 5 dir=up;
12291 else
12292 21487 newdir(4,homing,spw_wizzrobe);
12293 21531 }
12294
12295 2099229 void eWizzrobe::draw(BITMAP *dest)
12296 {
12297 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12298
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1056746 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2099229 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12299 125018 return;
12300
12301 1974211 int32_t tempint=dummy_int[1];
12302 1974211 bool tempbool1=dummy_bool[1];
12303 1974211 bool tempbool2=dummy_bool[2];
12304 1974211 dummy_int[1]=fclk;
12305 1974211 dummy_bool[1]=charging;
12306 1974211 dummy_bool[2]=firing;
12307 1974211 update_enemy_frame();
12308 1974211 dummy_int[1]=tempint;
12309 1974211 dummy_bool[1]=tempbool1;
12310 1974211 dummy_bool[2]=tempbool2;
12311 1974211 enemy::draw(dest);
12312 2099229 }
12313
12314 203 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12315 203 {
12316 203 fading=fade_flash_die;
12317
6/8
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 154 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 46 times.
203 if(dir==down&&y>=128)
12318 {
12319 3 dir=up;
12320 3 }
12321
12322
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
203 if(dir==right&&x>=208)
12323 {
12324 dir=left;
12325 }
12326
1/4
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if (SIZEflags != 0) init_size_flags();;
12327 203 }
12328
12329 125855 bool eDodongo::animate(int32_t index)
12330 {
12331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125855 times.
125855 if(switch_hooked) return enemy::animate(index);
12332
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 122065 times.
125855 if(dying)
12333 {
12334 3790 return Dead(index);
12335 }
12336
12337
2/2
✓ Branch 0 taken 121496 times.
✓ Branch 1 taken 569 times.
122065 if(clk==0)
12338 {
12339 569 removearmos(x,y,ffcactivated);
12340 569 }
12341
12342
2/2
✓ Branch 0 taken 10848 times.
✓ Branch 1 taken 111217 times.
122065 if(clk2) // ate a bomb
12343 {
12344
2/2
✓ Branch 0 taken 10735 times.
✓ Branch 1 taken 113 times.
10848 if(--clk2==0)
12345 113 hp-=misc; // store bomb's power in misc
12346 10848 }
12347 else
12348 111217 constant_walk(rate,homing,spw_clipright);
12349
12350 122065 hit_width = (dir<=down) ? 16 : 32;
12351 // hysz = (dir>=left) ? 16 : 32;
12352
12353 122065 return enemy::animate(index);
12354 125855 }
12355
12356 125845 void eDodongo::draw(BITMAP *dest)
12357 {
12358 125845 tile=o_tile;
12359
12360
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 122780 times.
125845 if(clk<0)
12361 {
12362 3065 enemy::drawzcboss(dest);
12363 3065 return;
12364 }
12365
12366 122780 update_enemy_frame();
12367 122780 enemy::drawzcboss(dest);
12368
12369
2/2
✓ Branch 0 taken 51662 times.
✓ Branch 1 taken 71118 times.
122780 if(dummy_int[1]!=0) //additional tiles
12370 {
12371 71118 tile+=dummy_int[1]; //second tile is previous tile
12372 71118 xofs-=16; //new xofs change
12373 71118 enemy::drawzcboss(dest);
12374 71118 xofs+=16;
12375 71118 }
12376
12377 125845 }
12378
12379 8218 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12380 {
12381 8218 int32_t wpnId = w->id;
12382 8218 int32_t power = w->power;
12383 8218 int32_t wpnx = w->x;
12384 8218 int32_t wpny = w->y;
12385
12386
5/12
✓ Branch 0 taken 8218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2457 times.
✓ Branch 5 taken 5761 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2457 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8218 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12387 5761 return 0;
12388
12389
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 1491 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
2457 switch(wpnId)
12390 {
12391 case wPhantom:
12392 return 0;
12393
12394 case wFire:
12395 case wBait:
12396 case wWhistle:
12397 case wWind:
12398 case wSSparkle:
12399 case wFSparkle:
12400 return 0;
12401
12402 case wLitBomb:
12403 case wLitSBomb:
12404
6/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 510 times.
✓ Branch 4 taken 690 times.
✓ Branch 5 taken 113 times.
803 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12405 690 return 0;
12406
12407 113 clk2=96;
12408 113 misc=power;
12409
12410
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 3 times.
113 if(wpnId==wLitSBomb)
12411 3 item_set=isSBOMB100;
12412
12413 113 return 1;
12414
12415 case wBomb:
12416 case wSBomb:
12417
6/6
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 1071 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 975 times.
1491 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12418 516 return 0;
12419
12420 975 stunclk=160;
12421 975 misc=wpnId; // store wpnId
12422 975 return 1;
12423
12424 case wSword:
12425
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 88 times.
146 if(stunclk)
12426 {
12427 88 sfx(WAV_EHIT,pan(int32_t(x)));
12428 88 hp=0;
12429 88 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12430 88 fading=0; // don't flash
12431 88 return 1;
12432 }
12433
12434 [[fallthrough]];
12435 default:
12436 75 sfx(WAV_CHINK,pan(int32_t(x)));
12437 75 }
12438
12439 75 return 1;
12440 8218 }
12441
12442 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12443 48 {
12444 48 fading=fade_flash_die;
12445 //nets+5180;
12446 48 previous_dir=-1;
12447
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12448 {
12449 1 dir=up;
12450 1 }
12451
12452
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12453 {
12454 dir=left;
12455 }
12456
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12457 48 }
12458
12459 39398 bool eDodongo2::animate(int32_t index)
12460 {
12461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12462
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12463 {
12464 1158 return Dead(index);
12465 }
12466
12467
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12468 {
12469 167 removearmos(x,y,ffcactivated);
12470 167 }
12471
12472
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12473 {
12474
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12475 42 hp-=misc; // store bomb's power in misc
12476 4032 }
12477 else
12478 34208 constant_walk(rate,homing,spw_clipbottomright);
12479
12480 38240 hit_width = (dir<=down) ? 16 : 32;
12481 38240 hit_height = (dir>=left) ? 16 : 32;
12482 38240 hxofs=(dir>=left)?-8:0;
12483 38240 hyofs=(dir<left)?-8:0;
12484
12485 38240 return enemy::animate(index);
12486 39398 }
12487
12488 39601 void eDodongo2::draw(BITMAP *dest)
12489 {
12490
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12491 {
12492 768 enemy::drawzcboss(dest);
12493 768 return;
12494 }
12495
12496 38833 int32_t tempx=xofs;
12497 38833 int32_t tempy=yofs;
12498 38833 update_enemy_frame();
12499 38833 enemy::drawzcboss(dest);
12500 38833 tile+=dummy_int[1]; //second tile change
12501 38833 xofs+=dummy_int[2]; //new xofs change
12502 38833 yofs+=dummy_int[3]; //new yofs change
12503 38833 enemy::drawzcboss(dest);
12504 38833 xofs=tempx;
12505 38833 yofs=tempy;
12506 39601 }
12507
12508 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12509 {
12510 3929 int32_t wpnId = w->id;
12511 3929 int32_t power = w->power;
12512 3929 int32_t wpnx = w->x;
12513 3929 int32_t wpny = w->y;
12514
12515
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12516 2377 return 0;
12517
12518
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12519 {
12520 case wPhantom:
12521 return 0;
12522
12523 case wFire:
12524 case wBait:
12525 case wWhistle:
12526 case wWind:
12527 case wSSparkle:
12528 case wFSparkle:
12529 346 return 0;
12530
12531 case wLitBomb:
12532 case wLitSBomb:
12533
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12534 {
12535 case up:
12536
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12537 77 return 0;
12538
12539 4 break;
12540
12541 case down:
12542
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12543 71 return 0;
12544
12545 6 break;
12546
12547 case left:
12548
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12549 66 return 0;
12550
12551 16 break;
12552
12553 case right:
12554
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12555 65 return 0;
12556
12557 16 break;
12558 }
12559
12560 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12561 // return 0;
12562 42 clk2=96;
12563 42 misc=power;
12564
12565
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12566 item_set=isSBOMB100;
12567
12568 42 return 1;
12569
12570 case wBomb:
12571 case wSBomb:
12572
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12573 {
12574 case up:
12575
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12576 84 return 0;
12577
12578 92 break;
12579
12580 case down:
12581
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12582 113 return 0;
12583
12584 55 break;
12585
12586 case left:
12587
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12588 80 return 0;
12589
12590 105 break;
12591
12592 case right:
12593
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12594 71 return 0;
12595
12596 93 break;
12597 }
12598
12599 345 stunclk=160;
12600 345 misc=wpnId; // store wpnId
12601 345 return 1;
12602
12603 case wSword:
12604
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12605 {
12606 34 sfx(WAV_EHIT,pan(int32_t(x)));
12607 34 hp=0;
12608 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12609 34 fading=0; // don't flash
12610 34 return 1;
12611 }
12612
12613 [[fallthrough]];
12614 default:
12615 158 sfx(WAV_CHINK,pan(int32_t(x)));
12616 158 }
12617
12618 158 return 1;
12619 3929 }
12620
12621 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12622 126 {
12623 //these are here to bypass compiler warnings about unused arguments
12624
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12625 {
12626
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 position_relative_to_screen(x, y, dmisc1 ? 64 : 176, 64);
12627 126 }
12628 else { x = X; y = Y; }
12629
12630 //nets+5940;
12631
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
12632 {
12633 81 }
12634 else
12635 {
12636
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 7 times.
45 if(dmisc1)
12637 {
12638 7 flip=1;
12639 7 }
12640 }
12641
12642
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12643 126 clk3=32;
12644 126 clk2=0;
12645 126 clk4=clk;
12646 126 dir=left;
12647
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if (SIZEflags != 0) init_size_flags();;
12648 126 }
12649
12650 71899 bool eAquamentus::animate(int32_t index)
12651 {
12652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
12653
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
12654 2092 return Dead(index);
12655
12656 // fbx=x+((id==eRAQUAM)?4:-4);
12657
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
12658 {
12659 317 removearmos(x,y,ffcactivated);
12660 317 }
12661
12662 69807 fbx=x;
12663
12664 /*
12665 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12666 {
12667 fbx+=16;
12668 }
12669 */
12670
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
12671 {
12672 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12673 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12674 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12675 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12676 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12677 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12678 450 sfx(wpnsfx(wpn),pan(int32_t(x)));
12679 450 }
12680
12681
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 21018 times.
✓ Branch 3 taken 345 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
12682 {
12683 345 clk3=32;
12684 345 }
12685
12686 69807 int screen_x = x.getInt()%256;
12687
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
12688 {
12689 1117 int32_t d2=(zc_oldrand()%3)+1;
12690
12691
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
12692 {
12693 752 dir=d2;
12694 752 }
12695
12696
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 385 times.
1117 if(dmisc1)
12697 {
12698
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(screen_x<=40)
12699 {
12700 38 dir=right;
12701 38 }
12702
12703
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(screen_x>=104)
12704 {
12705 dir=left;
12706 }
12707 385 }
12708 else
12709 {
12710
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(screen_x<=136)
12711 {
12712 21 dir=right;
12713 21 }
12714
12715
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(screen_x>=200)
12716 {
12717 34 dir=left;
12718 34 }
12719 }
12720 1117 }
12721
12722
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
12723 {
12724
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
12725 {
12726 4546 x-=1;
12727 4546 }
12728 else
12729 {
12730 3995 x+=1;
12731 }
12732 8541 }
12733
12734 69807 clk4=(clk4+1)%256;
12735
12736 69807 return enemy::animate(index);
12737 71899 }
12738
12739 72310 void eAquamentus::draw(BITMAP *dest)
12740 {
12741
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
12742 {
12743 44994 xofs=(dmisc1?-16:0);
12744
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12745
12746
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12747 {
12748 1312 xofs=0;
12749 1312 enemy::draw(dest);
12750 1312 }
12751 else
12752 {
12753 43682 drawblock(dest,15);
12754 }
12755 44994 }
12756 else
12757 {
12758 27316 int32_t xblockofs=((dmisc1)?-16:16);
12759 27316 xofs=0;
12760
12761
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
12762 {
12763 1462 enemy::draw(dest);
12764 1462 return;
12765 }
12766
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
12767 {
12768 // face (0=firing, 2=resting)
12769 25854 tile=o_tile+((clk3>0)?0:2);
12770 25854 enemy::draw(dest);
12771 // tail (
12772 25854 tile=o_tile+((clk&16)?1:3);
12773 25854 xofs=xblockofs;
12774 25854 enemy::draw(dest);
12775 // body
12776 25854 yofs+=16;
12777 25854 xofs=0;
12778 25854 tile=o_tile+((clk&16)?20:22);
12779 25854 enemy::draw(dest);
12780 25854 xofs=xblockofs;
12781 25854 tile=o_tile+((clk&16)?21:23);
12782 25854 enemy::draw(dest);
12783 25854 yofs-=16;
12784 25854 }
12785 else enemy::draw(dest);
12786 }
12787 72310 }
12788
12789 23834 bool eAquamentus::hit(weapon *w)
12790 {
12791
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12792
12793
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
12794 {
12795 case wBeam:
12796 case wRefBeam:
12797 case wMagic:
12798 4201 hit_height=32;
12799 4201 }
12800
12801
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12802 23834 hit_height=16;
12803 23834 return ret;
12804
12805 23834 }
12806
12807 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12808 93 {
12809
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12810 {
12811
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 position_relative_to_screen(x, y, 128, 48);
12812 93 }
12813 else { x = X; y = Y; }
12814
12815 93 Clk=Clk;
12816
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12817 {
12818 clk=0;
12819 superman = 1;
12820 fading=fade_flicker;
12821 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12822 }
12823
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12824 {
12825 42 clk=0;
12826 42 }
12827 93 hxofs=-16;
12828 93 hit_width=48;
12829 93 clk4=0;
12830
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12831
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12832
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12833
12834 //nets+5340;
12835 93 }
12836
12837 70891 bool eGohma::animate(int32_t index)
12838 {
12839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12840
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12841 1226 return Dead(index);
12842
12843
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12844 {
12845
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12846 {
12847 35 clk4=0;
12848 35 superman=0;
12849 35 fading=0;
12850 35 clk=0;
12851
12852 35 }
12853 1 else return enemy::animate(index);
12854 35 }
12855
12856
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12857 {
12858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if (ffcactivated) removearmosffc(*ffcactivated);
12859 else
12860 {
12861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12862 350 did_armos = false;
12863 350 removearmos(x,y);
12864 350 did_armos = false;
12865
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12866 }
12867 350 }
12868
12869
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12870
12871 // Movement clk must be separate from animation clk because of the Clock item
12872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12873 68878 clk4++;
12874
12875
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12876 {
12877
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12878 546 dir^=1;
12879 else
12880 486 dir=zc_oldrand()%3+1;
12881 1032 }
12882
12883
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12884 {
12885
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12886 {
12887 case 1:
12888 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12889 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12890 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12891 235 sfx(wpnsfx(wpn),pan(int32_t(x)));
12892 235 break;
12893
12894 default:
12895
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12896 {
12897 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12898 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12899 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12900 754 }
12901
12902 882 break;
12903 }
12904 1117 }
12905
12906
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12907 {
12908
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12909 {
12910 290 FireBreath(true);
12911 290 }
12912 2215 }
12913
12914
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12915 34479 move((zfix)1);
12916
12917
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
12918 150 clk3=0;
12919
12920 68878 return enemy::animate(index);
12921 70891 }
12922
12923 70889 void eGohma::draw(BITMAP *dest)
12924 {
12925 70889 tile=o_tile;
12926
12927
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
12928 {
12929 2012 enemy::drawzcboss(dest);
12930 2012 return;
12931 }
12932
12933
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
12934 {
12935 ///if ( do_animation )
12936 //Yuck. Gohma can just not have this capability right now.
12937 // left side
12938 53472 xofs=-16;
12939 53472 flip=0;
12940 // if(clk&16) tile=180;
12941 // else { tile=182; flip=1; }
12942 53472 tile+=(3*((clk&48)>>4));
12943 53472 enemy::drawzcboss(dest);
12944
12945 // right side
12946 53472 xofs=16;
12947 // tile=(180+182)-tile;
12948 53472 tile=o_tile;
12949 53472 tile+=(3*((clk&48)>>4))+2;
12950 53472 enemy::drawzcboss(dest);
12951
12952 // body
12953 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
12954 53472 tile=o_tile;
12955
12956 // tile+=(3*((clk&24)>>3))+2;
12957
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
12958 2975 tile+=7;
12959
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
12960 15890 tile+=10;
12961
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
12962 2051 tile+=7;
12963 else
12964 32556 tile+=((clk3-132)&24)?4:1;
12965
12966 53472 enemy::drawzcboss(dest);
12967
12968 53472 }
12969 else
12970 {
12971 // left side
12972 15405 xofs=-16;
12973 15405 flip=0;
12974
12975
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
12976 {
12977 7790 tile+=2;
12978 7790 flip=1;
12979 7790 }
12980
12981 15405 enemy::draw(dest);
12982
12983 // right side
12984 15405 tile=o_tile;
12985 15405 xofs=16;
12986
12987
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
12988
12989 // tile=(180+182)-tile;
12990 15405 enemy::draw(dest);
12991
12992 // body
12993 15405 tile=o_tile;
12994 15405 xofs=0;
12995
12996
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
12997 912 tile+=4;
12998
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
12999 4882 tile+=5;
13000
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
13001 585 tile+=4;
13002 9026 else tile+=((clk3-132)&8)?3:1;
13003
13004 15405 enemy::draw(dest);
13005
13006 }
13007 70889 }
13008
13009 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
13010 {
13011 578 int32_t wpnId = w->id;
13012 578 int32_t power = w->power;
13013 578 int32_t wpnx = w->x;
13014 578 int32_t wpnDir = w->dir;
13015 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
13016
13017
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
13018 {
13019
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
13020 {
13021 93 sfx(WAV_CHINK,pan(int32_t(x)));
13022 93 return 1;
13023 }
13024 328 }
13025
13026 485 return enemy::takehit(w, realweap);
13027 578 }
13028
13029 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13030 327 {
13031 327 count_enemy=(id==(id&0xFFF));
13032 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
13033
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if (SIZEflags != 0) init_size_flags();;
13034 327 }
13035
13036 124050 bool eLilDig::animate(int32_t index)
13037 {
13038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
13039
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
13040 4410 return Dead(index);
13041
13042
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
13043 {
13044 7105 removearmos(x,y,ffcactivated);
13045 7105 }
13046
13047
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
13048 {
13049
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
13050 1161 step+=0.25;
13051 38646 }
13052
13053 119640 variable_walk_8(rate,homing,hrate,spw_floater);
13054 119640 return enemy::animate(index);
13055 124050 }
13056
13057 124268 void eLilDig::draw(BITMAP *dest)
13058 {
13059 124268 tile = o_tile;
13060 // tile = 160;
13061 124268 int32_t fdiv = frate/4;
13062
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13063
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13064 124268 efrate:((clk>=(frate>>1))?1:0);
13065
13066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
13067 {
13068
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
13069 {
13070
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13071 {
13072 case up: //u
13073 11370 flip=0;
13074 11370 break;
13075
13076 case l_up: //d
13077 10699 flip=0;
13078 10699 tile+=4;
13079 10699 break;
13080
13081 case l_down: //l
13082 10722 flip=0;
13083 10722 tile+=8;
13084 10722 break;
13085
13086 case left: //r
13087 12015 flip=0;
13088 12015 tile+=12;
13089 12015 break;
13090
13091 case r_down: //ul
13092 10070 flip=0;
13093 10070 tile+=20;
13094 10070 break;
13095
13096 case down: //ur
13097 9554 flip=0;
13098 9554 tile+=24;
13099 9554 break;
13100
13101 case r_up: //dl
13102 8255 flip=0;
13103 8255 tile+=28;
13104 8255 break;
13105
13106 case right: //dr
13107 10033 flip=0;
13108 10033 tile+=32;
13109 10033 break;
13110 }
13111
13112 91457 tile+=f2;
13113 91457 }
13114 else
13115 {
13116 32811 tile+=(clk>=6)?1:0;
13117 }
13118 124268 }
13119
13120 124268 enemy::draw(dest);
13121 124268 }
13122
13123 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13124 80 {
13125
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 init_size_flags();
13126 80 }
13127
13128 29662 bool eBigDig::animate(int32_t index)
13129 {
13130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13132 return Dead(index);
13133
13134
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13135 {
13136 4104 removearmos(x,y,ffcactivated);
13137 4104 }
13138
13139
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13140 {
13141 case 0:
13142 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13143 29534 break;
13144
13145 case 1:
13146 64 ++misc;
13147 64 break;
13148
13149 case 2:
13150
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13151 {
13152 111 addenemy(screen_spawned,x,y,dmisc1+0x1000,-15);
13153 111 }
13154
13155
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13156 {
13157 30 addenemy(screen_spawned,x,y,dmisc2+0x1000,-15);
13158 30 }
13159
13160
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13161 {
13162 30 addenemy(screen_spawned,x,y,dmisc3+0x1000,-15);
13163 30 }
13164
13165
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13166 {
13167 30 addenemy(screen_spawned,x,y,dmisc4+0x1000,-15);
13168 30 }
13169
13170
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13171 {
13172 2 int guycarryingitem = guys.Count()-1;
13173 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13174 2 itemguy = false;
13175 2 }
13176
13177 64 stop_bgsfx(index);
13178
13179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
13180
13181 64 return true;
13182 }
13183
13184 29598 return enemy::animate(index);
13185 29662 }
13186
13187 29658 void eBigDig::draw(BITMAP *dest)
13188 {
13189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13190 {
13191 update_enemy_frame();
13192 xofs-=8;
13193 yofs-=8;
13194 drawblock(dest,15);
13195 xofs+=8;
13196 yofs+=8;
13197 return;
13198 }
13199
13200 29658 tile = o_tile;
13201 29658 int32_t fdiv = frate/4;
13202
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13203
13204
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13205 29658 efrate:((clk>=(frate>>1))?1:0);
13206
13207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13208 {
13209
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13210 {
13211
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13212 {
13213 case up: //u
13214 1688 flip=0;
13215 1688 break;
13216
13217 case l_up: //d
13218 1684 flip=0;
13219 1684 tile+=8;
13220 1684 break;
13221
13222 case l_down: //l
13223 2031 flip=0;
13224 2031 tile+=40;
13225 2031 break;
13226
13227 case left: //r
13228 1910 flip=0;
13229 1910 tile+=48;
13230 1910 break;
13231
13232 case r_down: //ul
13233 2041 flip=0;
13234 2041 tile+=80;
13235 2041 break;
13236
13237 case down: //ur
13238 2043 flip=0;
13239 2043 tile+=88;
13240
13241 2043 break;
13242
13243 case r_up: //dl
13244 1514 flip=0;
13245 1514 tile+=120;
13246 1514 break;
13247
13248 case right: //dr
13249 2241 flip=0;
13250 2241 tile+=128;
13251 2241 break;
13252 }
13253
13254 16161 tile+=(f2*2);
13255 16161 }
13256 else
13257 {
13258 13497 tile+=(f2)?0:2;
13259 13497 flip=(clk&1)?1:0;
13260 }
13261 29658 }
13262
13263 29658 xofs-=8;
13264 29658 yofs-=8;
13265 29658 drawblock(dest,15);
13266 29658 xofs+=8;
13267 29658 yofs+=8;
13268 29658 }
13269
13270 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13271 {
13272 869 int32_t wpnId = w->id;
13273
13274
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13275 64 misc=1;
13276
13277 869 return 0;
13278 }
13279
13280 80 void eBigDig::init_size_flags()
13281 {
13282 80 SIZEflags = d->SIZEflags;
13283
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13284 // al_trace("Enemy txsz:%i\n", txsz);
13285
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13286
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13287 80 else hit_width = 32;
13288
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13289 80 else hit_height = 32;
13290
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13291 80 else hzsz = 16; // hard to jump.
13292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13293 80 else hxofs = -8;
13294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13295 80 else hyofs = -8;
13296 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13297
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13298
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
13299 {
13300 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13301 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13302 }
13303
13304
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13305 80 }
13306
13307 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13308 13 {
13309 13 hxofs=hyofs=8;
13310
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
13311 {
13312 hxofs = 4;
13313 hyofs = 4;
13314 hit_width = 24;
13315 hit_height = 24;
13316 SIZEflags|=OVERRIDE_HIT_WIDTH;
13317 SIZEflags|=OVERRIDE_HIT_HEIGHT;
13318 }
13319 13 hzsz=16; //can't be jumped.
13320 13 clk2=70;
13321 13 misc=-1;
13322
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 mapscr* scr = get_scr(screen_spawned);
13323
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN));
13324 13 }
13325
13326 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13327 {
13328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
13329
13330 return Dead(index);
13331
13332
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
13333 {
13334 72 removearmos(x,y,ffcactivated);
13335 72 }
13336
13337
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
13338 {
13339 case -1:
13340 13 misc=0;
13341 [[fallthrough]];
13342 case 0:
13343
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
13344 {
13345 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13346 173 sfx(wpnsfx(wpn),pan(int32_t(x)));
13347 173 clk2=0;
13348 173 }
13349
13350 12693 Stunclk=0;
13351 12693 constant_walk(rate,homing,spw_none);
13352 12693 break;
13353
13354 case 1:
13355 case 2:
13356
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
13357 {
13358 41 int32_t r=zc_oldrand();
13359
13360
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
13361 {
13362 17 y=96;
13363
13364
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
13365 6 x=160;
13366 else
13367 11 x=48;
13368
13369
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
13370 8 x=208-x;
13371
13372 17 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
13373 17 }
13374
13375 41 loadpalset(csBOSS,pSprite(d->bosspal));
13376 41 misc=0;
13377 41 }
13378
13379 3607 break;
13380
13381 case 3:
13382 {
13383
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
13384 972 break;
13385
13386 12 misc=4;
13387 12 clk=0;
13388 12 hxofs=1000;
13389 12 loadpalset(9,pSprite(spPILE));
13390 12 music_stop();
13391 12 stop_sfx(WAV_ROAR);
13392
13393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13394
13395 12 sfx(WAV_GANON);
13396 //Ganon's dustpile; fall in sideview. -Z
13397 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13398 //dustpile->miscellaneous[31] = eeGANON;
13399
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13400 12 item *dustpile = NULL;
13401 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13402 12 dustpile = (item *)items.spr(items.Count() - 1);
13403 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13404 12 break;
13405 }
13406
13407 case 4:
13408
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
13409 {
13410 12 misc=5;
13411
13412 //game->lvlitems[dlevel]|=liBOSS;
13413
13414 12 sfx(WAV_CLEARED);
13415 //Add the big TF over the ashes!
13416
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
13417 {
13418 24 item *ashes = (item*)items.spr(q);
13419
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13420 {
13421 //Z_scripterrlog("Found correct dustpile!\n");
13422
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13423 12 item *bigtriforce = NULL;
13424 12 bigtriforce = (item *)items.spr(items.Count() - 1);
13425 12 bigtriforce->linked_parent = eeGANON;
13426 12 }
13427 24 }
13428 12 }
13429
13430 960 break;
13431 10 case 5: return true;
13432 }
13433
13434 18244 return enemy::animate(index);
13435 18254 }
13436
13437
13438 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13439 {
13440 //these are here to bypass compiler warnings about unused arguments
13441 964 int32_t wpnId = w->id;
13442 964 int32_t power = w->power;
13443 964 int32_t enemyHitWeapon = w->parentitem;
13444
13445
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
13446 {
13447 case 0:
13448
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
13449 31 return 0;
13450
13451 53 hp-=power;
13452
13453
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
13454 {
13455 41 misc=1;
13456 41 Stunclk=64;
13457 41 }
13458 else
13459 {
13460 12 loadpalset(csBOSS,pSprite(spBROWN));
13461 12 misc=2;
13462 12 Stunclk=284;
13463 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13464 }
13465
13466 53 sfx(WAV_EHIT,pan(int32_t(x)));
13467
13468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13469
13470 53 return 1;
13471
13472 case 2:
13473
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13474 154 return 0;
13475
13476 12 misc=3;
13477 12 hclk=81;
13478 12 loadpalset(9,pSprite(spBROWN));
13479 12 return 1;
13480 }
13481
13482 714 return 0;
13483 964 }
13484
13485 20776 void eGanon::draw(BITMAP *dest)
13486 {
13487
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
13488 {
13489 case 0:
13490
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
13491 3169 tile=(zc_oldrand()%5)*2+o_tile;
13492
13493
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13494 {
13495
13496 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13497 {
13498 int odraw = drawstyle;
13499 drawstyle = 2;
13500 drawblock(dest,15);
13501 drawstyle = odraw;
13502 }
13503 else
13504 {
13505 drawblock(dest,15);
13506 }
13507 break;
13508
13509 }
13510
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13511 {
13512 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13513 {
13514 int odraw = drawstyle;
13515 drawstyle = 2;
13516 drawblock(dest,15);
13517 drawstyle = odraw;
13518 }
13519 else
13520 {
13521 drawblock(dest,15);
13522 }
13523 break;
13524 }
13525
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
13526 12680 break;
13527 [[fallthrough]];
13528 case 2:
13529
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
13530 break;
13531 [[fallthrough]];
13532 case -1:
13533 3518 tile=o_tile;
13534
13535 [[fallthrough]];
13536 case 1:
13537 case 3:
13538 7126 drawblock(dest,15);
13539 7126 break;
13540
13541 case 4:
13542 960 draw_guts(dest);
13543 960 draw_flash(dest);
13544 960 break;
13545 }
13546 20776 }
13547
13548 960 void eGanon::draw_guts(BITMAP *dest)
13549 {
13550
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
13551 960 tile = clk<24 ? 74 : 75;
13552 960 overtile16(dest,tile,x+8-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13553 960 overtile16(dest,tile,x+8-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13554 960 overtile16(dest,tile,x+c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13555 960 overtile16(dest,tile,x+16-c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13556 960 overtile16(dest,tile,x+c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13557 960 overtile16(dest,tile,x+16-c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13558 960 overtile16(dest,tile,x+c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13559 960 overtile16(dest,tile,x+16-c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13560 960 }
13561
13562 960 void eGanon::draw_flash(BITMAP *dest)
13563 {
13564
13565 960 int32_t c = clk-(clk>>2);
13566 960 cs = (frame&3)+6;
13567 960 overtile16(dest,194,x+8-viewport.x,y+8-clk+playing_field_offset-viewport.y,cs,0);
13568 960 overtile16(dest,194,x+8-viewport.x,y+8+clk+playing_field_offset-viewport.y,cs,2);
13569 960 overtile16(dest,195,x+8-clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,0);
13570 960 overtile16(dest,195,x+8+clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,1);
13571 960 overtile16(dest,196,x+8-c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,0);
13572 960 overtile16(dest,196,x+8+c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,1);
13573 960 overtile16(dest,196,x+8-c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,2);
13574 960 overtile16(dest,196,x+8+c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,3);
13575 960 }
13576
13577 15 void getBigTri(mapscr* scr, int32_t id2)
13578 {
13579 /*
13580 *************************
13581 * BIG TRIFORCE SEQUENCE *
13582 *************************
13583 0 BIGTRI out, WHITE flash in
13584 4 WHITE flash out, PILE cset white
13585 8 WHITE in
13586 ...
13587 188 WHITE out
13588 191 PILE cset red
13589 200 top SHUTTER opens
13590 209 bottom SHUTTER opens
13591 */
13592 15 sfx(itemsbuf[id2].playsound);
13593 15 guys.clear();
13594
13595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(itemsbuf[id2].flags & item_gamedata)
13596 {
13597 game->lvlitems[dlevel]|=liTRIFORCE;
13598 }
13599
13600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13601
13602 15 draw_screen();
13603
13604
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2880 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2880 times.
2895 for(int32_t f=0; f<24*8 && !Quit; f++)
13605 {
13606
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==4)
13607 {
13608
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 15 times.
240 for(int32_t i=1; i<16; i++)
13609 {
13610 225 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13611 225 }
13612 15 }
13613
13614
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==0)
13615 {
13616
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 360 times.
1440 for(int32_t cs=2; cs<5; cs++)
13617 {
13618
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 1080 times.
17280 for(int32_t i=1; i<16; i++)
13619 {
13620 16200 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
13621 16200 }
13622 1080 }
13623
13624 360 refreshpal=true;
13625 360 }
13626
13627
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==4)
13628 {
13629
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if(cur_screen<128) loadlvlpal(DMaps[cur_dmap].color);
13630 else loadlvlpal(0xB);
13631 360 }
13632
13633
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==191)
13634 {
13635 15 loadpalset(9,pSprite(spPILE));
13636 15 }
13637
13638 2880 advanceframe(true);
13639 2880 }
13640
13641 //play_DmapMusic();
13642 15 playLevelMusic();
13643
13644
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
15 if(itemsbuf[id2].flags & item_flag1 && cur_screen < 128)
13645 {
13646 2 Hero.dowarp(hero_scr, 1, 0); //side warp
13647 2 }
13648 15 }
13649
13650 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
13651 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13652 618 {
13653
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
13654 {
13655
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 position_relative_to_screen(x, y, 128, 48);
13656 618 }
13657 //else { x = X; y = Y; }
13658
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
13659 618 superman=1;
13660 618 fading=fade_invisible;
13661 618 hxofs=1000;
13662 618 segcnt=clk;
13663 618 segid=Id|0x1000;
13664 618 clk=0;
13665
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
13666
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13667 618 tile=o_tile;
13668 618 hitdir = -1;
13669 618 stickclk = 0;
13670
13671 /*
13672 if (get_qr(qr_NEWENEMYTILES))
13673 {
13674 tile=nets+1220;
13675 }
13676 else
13677 {
13678 tile=57;
13679 }
13680 */
13681 618 }
13682
13683 244844 bool eMoldorm::animate(int32_t index)
13684 {
13685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
13686 244844 int32_t max_y = isdungeon(screen_spawned) ? 100 : 100+28; //warning: Ugly hack. -Z
13687
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
13688 {
13689 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
13690 //Z_scripterrlog("Stickclk is %d\n", stickclk);
13691 28475 }
13692
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
13693 {
13694 562 stickclk = 0;
13695 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
13696 562 }
13697
13698
13699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
13700 {
13701 244844 removearmos(x,y,ffcactivated);
13702 244844 }
13703
13704
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
13705 {
13706
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
13707 {
13708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_never_return)
13709 129 never_return(screen_spawned, index);
13710
13711
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
13712 129 leave_item();
13713
13714 129 stop_bgsfx(index);
13715 129 return true;
13716 }
13717 2322 }
13718 else
13719 {
13720
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
13721 stunclk=0;
13722 242393 constant_walk_8_old(rate,homing,spw_floater);
13723
13724
13725 242393 misc=dir;
13726
13727 // If any higher-numbered segments were killed, segcnt can be too high,
13728 // leading to a crash
13729
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
13730 segcnt=guys.Count()-index-1;
13731
13732
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
13733 {
13734 1122281 enemy* segment=((enemy*)guys.spr(i));
13735
13736 // More validation - if segcnt was wrong, this may not
13737 // actually be a Moldorm segment
13738
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
13739 {
13740 segcnt=i-index-1;
13741 break;
13742 }
13743
13744
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
13745 {
13746 242669 x=segment->x;
13747 242669 y=segment->y;
13748 242669 }
13749
13750 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
13751 //Script your own blasted segmented bosses!! -Z
13752 1122281 segment->parent_uid = this->getUID();
13753
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
13754 {
13755 217733 segment->dummy_int[1]=2;
13756 217733 }
13757 else
13758 {
13759 904548 segment->dummy_int[1]=1;
13760 }
13761
13762
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
13763 {
13764 242669 segment->dummy_int[1]=0;
13765 242669 }
13766
13767
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
13768 {
13769 1016 int32_t offset=1;
13770
13771
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
13772 {
13773 // Triple-check
13774
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
13775 {
13776 segcnt=j-index+1; // Add 1 because of --segcnt below
13777 break;
13778 }
13779 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
13780 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
13781 1480 }
13782
13783 1016 segment->hclk=33;
13784 1016 --segcnt;
13785 1016 --i; // Recheck the same index in case multiple segments died at once
13786 1016 }
13787 1122281 }
13788
13789
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 242264 times.
242393 if(segcnt==0)
13790 {
13791 129 clk2=19;
13792
13793 129 x=guys.spr(index+1)->x;
13794 129 y=guys.spr(index+1)->y;
13795 129 }
13796 }
13797
13798 244715 return false;
13799 244844 }
13800
13801 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13802 3150 {
13803
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
13804 {
13805
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 position_relative_to_screen(x, y, 128, 48);
13806 3150 }
13807
13808
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13809 3150 hyofs=4;
13810 3150 hit_width=hit_height=8;
13811 3150 hxofs=1000;
13812 3150 mainguy=count_enemy=false;
13813 3150 parentclk = 0;
13814 3150 bgsfx=-1;
13815
2/4
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 flags&=~guy_never_return;
13816 //deadsfx = WAV_EDEAD;
13817 3150 isCore = false;
13818 3150 }
13819
13820 1138024 bool esMoldorm::animate(int32_t index)
13821 {
13822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
13823 // Shouldn't be possible, but better to be sure
13824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
13825 dying=true;
13826
13827
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
13828 {
13829
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
13830 15743 item_set=0;
13831
13832 15743 return Dead(index);
13833 }
13834
13835
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
13836 {
13837 1017204 hxofs=4;
13838 1017204 step=((enemy*)guys.spr(index-1))->step;
13839
13840
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
13841 {
13842 70455 misc=dir;
13843 70455 dir=((enemy*)guys.spr(index-1))->misc;
13844 //do alignment, as in parent's animation :-/ -DD
13845 70455 x.doFloor();
13846 70455 y.doFloor();
13847 70455 }
13848
13849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
13850 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
13851
13852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
13853 {
13854 1017204 sprite::move(step);
13855 1017204 }
13856 1017204 }
13857
13858 1122281 return enemy::animate(index);
13859 1138024 }
13860
13861 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
13862 {
13863
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
13864 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
13865
13866 453 return 0;
13867 2683 }
13868
13869 1155313 void esMoldorm::draw(BITMAP *dest)
13870 {
13871 1155313 tile=o_tile;
13872 1155313 int32_t fdiv = frate/4;
13873
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13874
13875
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13876 1155313 efrate:((clk>=(frate>>1))?1:0);
13877
13878
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
13879 {
13880 1043930 tile+=dummy_int[1]*40;
13881
13882
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
13883 {
13884 102730 flip=0;
13885
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
13886
13887
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
13888 tile+=4;
13889 102730 }
13890 else
13891 {
13892
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
13893 {
13894 case up: //u
13895 96530 flip=0;
13896 96530 break;
13897
13898 case l_up: //d
13899 134534 flip=0;
13900 134534 tile+=4;
13901 134534 break;
13902
13903 case l_down: //l
13904 113426 flip=0;
13905 113426 tile+=8;
13906 113426 break;
13907
13908 case left: //r
13909 124800 flip=0;
13910 124800 tile+=12;
13911 124800 break;
13912
13913 case r_down: //ul
13914 101314 flip=0;
13915 101314 tile+=20;
13916 101314 break;
13917
13918 case down: //ur
13919 99043 flip=0;
13920 99043 tile+=24;
13921 99043 break;
13922
13923 case r_up: //dl
13924 131794 flip=0;
13925 131794 tile+=28;
13926 131794 break;
13927
13928 case right: //dr
13929 139759 flip=0;
13930 139759 tile+=32;
13931 139759 break;
13932 }
13933 }
13934
13935 1043930 tile+=f2;
13936 1043930 }
13937
13938
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
13939 1049046 enemy::draw(dest);
13940 1155313 }
13941
13942 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
13943 420 {
13944
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
13945 {
13946
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 position_relative_to_screen(x, y, 64, 80);
13947 420 }
13948 //else { x = X; y = Y; }
13949 //byte legaldirs = 0;
13950 420 int32_t incr = 16;
13951 //int32_t possiiblepos = 0;
13952 //int32_t positions[8] = {0};
13953
13954 //Don't spawn in pits.
13955
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
13956 {
13957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
13958 {
13959 //move if we spawn over a pit
13960 //check each direction
13961
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
13962 {
13963
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
13964 }
13965
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
13966 {
13967
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
13968 }
13969
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
13970 {
13971
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
13972 }
13973
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
13974 {
13975
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
13976 }
13977
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
13978 {
13979 y -= incr; break;
13980 }
13981
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
13982 {
13983 y+=incr; break;
13984 }
13985
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
13986 {
13987
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
13988 }
13989
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
13990 {
13991 x+=incr; y+=incr; break;
13992 }
13993 34 else continue;
13994
13995 }
13996
13997 105 }
13998
13999 420 dir=up;
14000 420 superman=1;
14001 420 fading=fade_invisible;
14002 420 hxofs=1000;
14003 420 segcnt=clk;
14004 420 clk=0;
14005 //set up move history
14006
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
14007
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14008 420 }
14009
14010 236907 bool eLanmola::animate(int32_t index)
14011 {
14012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
14013
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
14014 {
14015 40196 removearmos(x,y,ffcactivated);
14016 40196 }
14017
14018
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
14019 {
14020
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
14021 {
14022
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14023 86 leave_item();
14024
14025 189 stop_bgsfx(index);
14026 189 return true;
14027 }
14028
14029 3402 return false;
14030 }
14031
14032
14033 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14034 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14035 //I've added a complete movement history to this enemy to compensate -DD
14036 233316 constant_walk(rate,homing,spw_none);
14037 233316 prevState.pop_front();
14038 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14039
14040 // This could cause a crash with Moldorms. I didn't see the same problem
14041 // with Lanmolas, but it looks like it ought to be possible, so here's
14042 // the same solution. - Saf
14043
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
14044 segcnt=guys.Count()-index-1;
14045
14046
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
14047 {
14048 966396 enemy* segment=((enemy*)guys.spr(i));
14049
14050 // More validation in case segcnt is wrong
14051
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
14052 {
14053 segcnt=i-index-1;
14054 break;
14055 }
14056
14057 966396 segment->o_tile=o_tile;
14058 966396 segment->parent_uid = this->getUID();
14059
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
14060 {
14061 195700 segment->dummy_int[1]=1; //tail
14062 195700 }
14063 else
14064 {
14065 770696 segment->dummy_int[1]=0;
14066 }
14067
14068
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
14069 {
14070
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
14071 {
14072 // Triple-check
14073
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14074 {
14075 segcnt=j-index+1; // Add 1 because of --segcnt below
14076 break;
14077 }
14078 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14079 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14080 1961 }
14081
14082 1169 ((enemy*)guys.spr(i))->hclk=33;
14083 1169 --segcnt;
14084 1169 --i; // Recheck the same index in case multiple segments died at once
14085 1169 }
14086 966396 }
14087
14088
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
14089 {
14090 189 clk2=19;
14091 189 x=guys.spr(index+1)->x;
14092 189 y=guys.spr(index+1)->y;
14093 189 setmapflag(get_scr(screen_spawned), mTMPNORET);
14094 189 }
14095
14096 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14097 //which is... disastrous.
14098 233316 hp = 1;
14099 233316 return enemy::animate(index);
14100 236907 }
14101
14102 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14103 2267 {
14104
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
14105 {
14106
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 position_relative_to_screen(x, y, 64, 80);
14107 2267 }
14108 2267 int32_t incr = 16;
14109 //Don't spawn in pits.
14110
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14111 {
14112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14113 {
14114 //move if we spawn over a pit
14115 //check each direction
14116
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14117 {
14118
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14119 }
14120
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14121 {
14122
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14123 }
14124
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14125 {
14126
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14127 }
14128
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14129 {
14130
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14131 }
14132
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14133 {
14134 y -= incr; break;
14135 }
14136
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14137 {
14138 y+=incr; break;
14139 }
14140
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14141 {
14142
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14143 }
14144
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14145 {
14146 x+=incr; y+=incr; break;
14147 }
14148 170 else continue;
14149
14150 }
14151
14152 525 }
14153
14154 2267 hxofs=1000;
14155 2267 hit_width=8;
14156 2267 mainguy=false;
14157 2267 count_enemy=(id<0x2000)?true:false;
14158
14159 //set up move history
14160
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14161
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14162
14163 2267 bgsfx = -1;
14164 2267 isCore = false;
14165
2/4
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
2267 flags&=~guy_never_return;
14166 2267 }
14167
14168 985563 bool esLanmola::animate(int32_t index)
14169 {
14170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14171 // Shouldn't be possible, but who knows
14172
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14173 18 dying=true;
14174
14175
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14176 {
14177 19167 xofs=0;
14178
14179
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14180 9306 item_set=0;
14181
14182 19167 return Dead(index);
14183 }
14184
14185
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14186 {
14187 930450 hxofs=4;
14188
14189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14190 {
14191 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14192 930450 prevState.pop_front();
14193 930450 prevState.push_back(newstate);
14194 930450 x = newstate.first.first;
14195 930450 y = newstate.first.second;
14196 930450 dir = newstate.second;
14197 930450 }
14198 930450 }
14199
14200 966396 return enemy::animate(index);
14201 985563 }
14202
14203 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14204 {
14205
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14206 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14207
14208 590 return 0;
14209 2655 }
14210
14211 990931 void esLanmola::draw(BITMAP *dest)
14212 {
14213 990931 tile=o_tile;
14214 990931 int32_t fdiv = frate/4;
14215
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14216
14217
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14218 990931 efrate:((clk>=(frate>>1))?1:0);
14219
14220
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14221 {
14222
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14223 {
14224 481767 tile+=20;
14225
14226
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14227 {
14228 128742 tile+=20;
14229 128742 }
14230 481767 }
14231
14232
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14233 {
14234 case up:
14235 141419 flip=0;
14236 141419 break;
14237
14238 case down:
14239 140994 flip=0;
14240 140994 tile+=4;
14241 140994 break;
14242
14243 case left:
14244 159500 flip=0;
14245 159500 tile+=8;
14246 159500 break;
14247
14248 case right:
14249 187019 flip=0;
14250 187019 tile+=12;
14251 187019 break;
14252 }
14253
14254 628932 tile+=f2;
14255 628932 }
14256 else
14257 {
14258
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
14259 {
14260 271456 tile+=1;
14261 271456 }
14262 }
14263
14264
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
14265 953893 enemy::draw(dest);
14266 990931 }
14267
14268 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14269 150 {
14270 //these are here to bypass compiler warnings about unused arguments
14271 150 Clk=Clk;
14272 150 superman=1;
14273
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14274 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14275
14276
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14277 692 arm[i]=i;
14278
14279 150 fading=fade_blue_poof;
14280 //nets+4680;
14281 150 adjusted=false;
14282
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14283 150 }
14284
14285 66494 bool eManhandla::animate(int32_t index)
14286 {
14287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14288
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14289 1382 return Dead(index);
14290
14291
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14292 {
14293 2471 removearmos(x,y,ffcactivated);
14294 2471 }
14295
14296
14297 // check arm status, move dead ones to end of group
14298
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14299 {
14300 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14301
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14302 {
14303
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14304 {
14305 552 zc_swap(arm[j],arm[j+1]);
14306 552 guys.swap(index+j+1,index+j+2);
14307 552 }
14308
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14309 {
14310 87 leave_item();
14311 87 }
14312 424 --armcnt;
14313 424 --i;
14314 424 continue;
14315 }
14316
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14317 {
14318
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14319 {
14320 508 cur_arm->o_tile=o_tile+40;
14321 508 cur_arm->parent_uid = this->getUID();
14322 508 }
14323 else
14324 {
14325 184 cur_arm->o_tile=o_tile+160;
14326 184 cur_arm->parent_uid = this->getUID();
14327 }
14328 692 }
14329 193194 }
14330
14331 65112 adjusted=true;
14332
14333 // move or die
14334
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14335 83 hp=0;
14336 else
14337 {
14338 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14339
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14340
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14341 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14342
14343
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14344 {
14345
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14346 {
14347
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14348 {
14349 case 0:
14350 38579 dy1=-24;
14351 38579 break;
14352
14353 case 1:
14354 36328 dy2=31;
14355 36328 break;
14356
14357 case 2:
14358 36250 dx1=-16;
14359 36250 break;
14360
14361 case 3:
14362 39862 dx2=31;
14363 39862 break;
14364 }
14365 151019 }
14366 53584 }
14367 else
14368 {
14369 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14370
14371
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14372 {
14373
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14374 {
14375 case 0:
14376 12012 dy1=-32;
14377 12012 break;
14378
14379 case 1:
14380 7730 dy2=39;
14381 7730 break;
14382
14383 case 2:
14384 9837 dx1=-24;
14385 9837 break;
14386
14387 case 3:
14388 12596 dx2=39;
14389 12596 break;
14390 }
14391 42175 }
14392 }
14393
14394 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14395
14396
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14397 {
14398 193194 zfix dx=(zfix)0,dy=(zfix)0;
14399
14400
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14401 {
14402
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14403 {
14404 case 0:
14405 38579 dy=-16;
14406 38579 break;
14407
14408 case 1:
14409 36328 dy=16;
14410 36328 break;
14411
14412 case 2:
14413 36250 dx=-16;
14414 36250 break;
14415
14416 case 3:
14417 39862 dx=16;
14418 39862 break;
14419 }
14420 151019 }
14421 else
14422 {
14423
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14424 {
14425 case 0:
14426 5447 dy=-24;
14427 5447 dx=-8;
14428 5447 break;
14429
14430 case 1:
14431 3986 dy=24;
14432 3986 dx=8;
14433 3986 break;
14434
14435 case 2:
14436 4163 dx=-24;
14437 4163 dy=8;
14438 4163 break;
14439
14440 case 3:
14441 6774 dx=24;
14442 6774 dy=-8;
14443 6774 break;
14444
14445 case 4:
14446 6565 dy=-24;
14447 6565 dx=8;
14448 6565 break;
14449
14450 case 5:
14451 3744 dy=24;
14452 3744 dx=-8;
14453 3744 break;
14454
14455 case 6:
14456 5674 dx=-24;
14457 5674 dy=-8;
14458 5674 break;
14459
14460 case 7:
14461 5822 dx=24;
14462 5822 dy=8;
14463 5822 break;
14464 }
14465 }
14466
14467 193194 guys.spr(index+i+1)->x = x+dx;
14468 193194 guys.spr(index+i+1)->y = y+dy;
14469 193194 }
14470 }
14471
14472 65112 return enemy::animate(index);
14473 66494 }
14474
14475
14476 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14477 {
14478 1751 int32_t wpnId = w->id;
14479
14480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14481 return 0;
14482
14483
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14484 {
14485 case wBomb:
14486 case wSBomb:
14487 case wSword:
14488 case wHammer:
14489 case wWand:
14490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14491
14492 case wLitBomb:
14493 case wLitSBomb:
14494 case wBait:
14495 case wWhistle:
14496 case wFire:
14497 case wWind:
14498 case wSSparkle:
14499 case wFSparkle:
14500 case wPhantom:
14501 1709 return 0;
14502
14503 case wHookshot:
14504 case wBrang:
14505 sfx(WAV_CHINK,pan(int32_t(x)));
14506 break;
14507
14508 default:
14509
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14510 else sfx(WAV_CHINK,pan(int32_t(x)));
14511
14512 42 }
14513
14514 42 return 1;
14515 1751 }
14516
14517 66490 void eManhandla::draw(BITMAP *dest)
14518 {
14519 66490 tile=o_tile;
14520 66490 int32_t fdiv = frate/4;
14521
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14522
14523
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14524 66490 efrate:((clk>=(frate>>1))?1:0);
14525
14526
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14527 {
14528
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14529 {
14530
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14531 {
14532 case up: //u
14533 4771 flip=0;
14534 4771 break;
14535
14536 case l_up: //d
14537 4640 flip=0;
14538 4640 tile+=4;
14539 4640 break;
14540
14541 case l_down: //l
14542 4995 flip=0;
14543 4995 tile+=8;
14544 4995 break;
14545
14546 case left: //r
14547 5574 flip=0;
14548 5574 tile+=12;
14549 5574 break;
14550
14551 case r_down: //ul
14552 3793 flip=0;
14553 3793 tile+=20;
14554 3793 break;
14555
14556 case down: //ur
14557 3930 flip=0;
14558 3930 tile+=24;
14559 3930 break;
14560
14561 case r_up: //dl
14562 3908 flip=0;
14563 3908 tile+=28;
14564 3908 break;
14565
14566 case right: //dr
14567 5883 flip=0;
14568 5883 tile+=32;
14569 5883 break;
14570 }
14571
14572 37494 tile+=f2;
14573 37494 enemy::draw(dest);
14574 37494 } //manhandla 2, big body
14575 else
14576 {
14577
14578
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14579 {
14580 case up: //u
14581 1277 flip=0;
14582 1277 break;
14583
14584 case l_up: //d
14585 1360 flip=0;
14586 1360 tile+=8;
14587 1360 break;
14588
14589 case l_down: //l
14590 2242 flip=0;
14591 2242 tile+=40;
14592 2242 break;
14593
14594 case left: //r
14595 1789 flip=0;
14596 1789 tile+=48;
14597 1789 break;
14598
14599 case r_down: //ul
14600 1345 flip=0;
14601 1345 tile+=80;
14602 1345 break;
14603
14604 case down: //ur
14605 805 flip=0;
14606 805 tile+=88;
14607 805 break;
14608
14609 case r_up: //dl
14610 948 flip=0;
14611 948 tile+=120;
14612 948 break;
14613
14614 case right: //dr
14615 1542 flip=0;
14616 1542 tile+=128;
14617 1542 break;
14618 }
14619
14620 11308 tile+=(f2*2);
14621 11308 xofs-=8;
14622 11308 yofs-=8;
14623 11308 drawblock(dest,15);
14624 11308 xofs+=8;
14625 11308 yofs+=8;
14626 }
14627 48802 }
14628 else
14629 {
14630
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
14631 {
14632 17173 enemy::draw(dest);
14633 17173 }
14634 else
14635 {
14636 515 xofs-=8;
14637 515 yofs-=8;
14638 515 enemy::draw(dest);
14639 515 xofs+=16;
14640 515 enemy::draw(dest);
14641 515 yofs+=16;
14642 515 enemy::draw(dest);
14643 515 xofs-=16;
14644 515 enemy::draw(dest);
14645 515 xofs+=8;
14646 515 yofs-=8;
14647 }
14648 }
14649 66490 }
14650
14651 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14652 692 {
14653 692 id=misc=clk;
14654 692 dir = clk & 3;
14655 692 clk=0;
14656 692 mainguy=count_enemy=false;
14657 692 dummy_bool[0]=false;
14658 692 item_set=0;
14659 692 bgsfx=-1;
14660 692 deadsfx = WAV_EDEAD;
14661
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
14662 692 isCore = false;
14663
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
14664 692 }
14665
14666 200202 bool esManhandla::animate(int32_t index)
14667 {
14668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
14669
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
14670 7008 return Dead(index);
14671
14672
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
14673 {
14674 12404 removearmos(x,y,ffcactivated);
14675 12404 }
14676
14677
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
14678 {
14679 27896 clk2=unsigned(zc_oldrand())%5+5;
14680 27896 clk3^=1;
14681 27896 }
14682
14683
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
14684 {
14685 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14686 1491 sfx(wpnsfx(wpn),pan(int32_t(x)));
14687 1491 }
14688
14689 193194 return enemy::animate(index);
14690 200202 }
14691
14692 200186 void esManhandla::draw(BITMAP *dest)
14693 {
14694 200186 tile=o_tile;
14695 200186 int32_t fdiv = frate/4;
14696
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14697
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14698 200186 efrate:((clk>=(frate>>1))?1:0);
14699
14700
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
14701 {
14702
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
14703 {
14704 case up:
14705 39945 break;
14706
14707 case down:
14708 36845 tile+=4;
14709 36845 break;
14710
14711 case left:
14712 39966 tile+=8;
14713 39966 break;
14714
14715 case right:
14716 41960 tile+=12;
14717 41960 break;
14718 }
14719
14720 158716 tile+=f2;
14721 158716 }
14722 else
14723 {
14724
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
14725 {
14726 case down:
14727 8961 flip=2;
14728
14729 [[fallthrough]];
14730 case up:
14731 21355 tile=(clk3)?188:189;
14732 21355 break;
14733
14734 case right:
14735 12232 flip=1;
14736 [[fallthrough]];
14737
14738 case left:
14739 20115 tile=(clk3)?186:187;
14740 20115 break;
14741 }
14742 }
14743
14744 200186 enemy::draw(dest);
14745 200186 }
14746
14747 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
14748 168 {
14749
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
14750 {
14751
2/4
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
168 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, 120, 48);
14752 168 }
14753 else
14754 {
14755 if ( !(editorflags & ENEMY_FLAG6) )
14756 {
14757 x = X; y = Y;
14758 }
14759 else
14760 {
14761 x = X+8; y = Y;
14762 }
14763 }
14764 168 hzsz = 32; // can't be jumped.
14765 168 flameclk=0;
14766 168 misc=clk; // total head count
14767 168 clk3=clk; // live head count
14768 168 clk=0;
14769 168 clk2=60; // fire ball clock
14770 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
14771
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
14772 168 dir = down;
14773 168 hxofs=4;
14774 168 hit_width=8;
14775 // frate=17*4;
14776 168 fading=fade_blue_poof;
14777 //nets+5420;
14778
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
14779 {
14780 /*
14781 necktile=o_tile+8;
14782 if (dmisc3)
14783 {
14784 necktile+=8;
14785 }
14786 */
14787 133 necktile=o_tile+dmisc6;
14788 133 }
14789 else
14790 {
14791 35 necktile=s_tile;
14792 }
14793 168 }
14794
14795 155290 bool eGleeok::animate(int32_t index)
14796 {
14797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
14798
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
14799 2199 return Dead(index);
14800
14801
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
14802 {
14803 684 removearmos(x,y,ffcactivated);
14804 684 }
14805
14806 // Check if a head was killed somehow...
14807
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
14808 51372 clk3=guys.Count()-index-1;
14809
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
14810 87041 misc=guys.Count()-index-1;
14811
14812 //fix for the "kill all enemies" item
14813
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
14814 {
14815
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
14816 {
14817 // I haven't seen this fail, but it seems like it ought to be
14818 // possible, so I'm checking for it. - Saf
14819
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14820 break;
14821 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
14822 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
14823 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
14824 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
14825 12 }
14826
14827 6 clk3=0;
14828
14829
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
14830 {
14831
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14832 break;
14833 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14834 12 }
14835 6 }
14836
14837
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
14838 {
14839 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
14840 403171 head->dummy_int[1]=necktile;
14841 403171 head->parent_uid = this->getUID();
14842
14843
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
14844 {
14845 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
14846 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
14847 320127 }
14848 else
14849 {
14850 83044 head->dummy_int[2]=necktile+1; //connected head tile
14851 83044 head->dummy_int[3]=necktile+2; //flying head tile
14852 }
14853
14854 403171 head->dmisc5=dmisc5; //neck segments
14855
14856 /*
14857 if (dmisc3)
14858 {
14859 head->dummy_bool[0]=true;
14860 }
14861 */
14862
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
14863 {
14864
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
14865 {
14866 1228 hp -= 1000 - head->hp;
14867 1228 hclk = 33;
14868
14869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
14870
14871 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
14872 1228 }
14873
14874 5655 head->hclk = 0;
14875 5655 }
14876
14877 // Must be set in case of naughty ZScripts
14878 403171 head->hp = 1000;
14879 403171 }
14880
14881
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
14882 {
14883 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
14884 415 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
14885 415 }
14886
14887
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
14888 {
14889
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
14890 {
14891 1287 int32_t i=zc_oldrand()%misc;
14892 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
14893 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
14894 1287 sfx(wpnsfx(wpn),pan(int32_t(x)));
14895 1287 clk2=0;
14896 1287 }
14897 95682 }
14898 else
14899 {
14900
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
14901 {
14902 557 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
14903 557 head->timer=zc_oldrand()%50+50;
14904 557 clk2=0;
14905 557 }
14906 }
14907
14908
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
14909 {
14910
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
14911 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14912
14913
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_never_return) never_return(screen_spawned, index);
14914 127 }
14915
14916 153091 return enemy::animate(index);
14917 155290 }
14918
14919 1239 int32_t eGleeok::takehit(weapon*,weapon*)
14920 {
14921 1239 return 0;
14922 }
14923
14924 156918 void eGleeok::draw(BITMAP *dest)
14925 {
14926 156918 tile=o_tile;
14927
14928
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
14929 {
14930 2199 enemy::draw(dest);
14931 2199 return;
14932 }
14933
14934 154719 int32_t f=clk/17;
14935
14936
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
14937 {
14938 // body
14939 120524 xofs=-8;
14940 120524 yofs=32;
14941
14942
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
14943
14944 {
14945 case 0:
14946 9155 tile+=0;
14947 9155 break;
14948
14949 case 1:
14950 10095 tile+=2;
14951 10095 break;
14952
14953 case 2:
14954 8686 tile+=4;
14955 8686 break;
14956
14957 default:
14958 92588 tile+=6;
14959 92588 break;
14960 }
14961 120524 }
14962 else
14963 {
14964 // body
14965 34195 xofs=-8;
14966 34195 yofs=32;
14967
14968
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
14969 {
14970 case 0:
14971 2514 tile+=0;
14972 2514 break;
14973
14974 case 2:
14975 2459 tile+=4;
14976 2459 break;
14977
14978 default:
14979 29222 tile+=2;
14980 29222 break;
14981 }
14982 }
14983
14984 154719 enemy::drawblock(dest,15);
14985 156918 }
14986
14987 156918 void eGleeok::draw2(BITMAP *dest)
14988 {
14989 // the neck stub
14990 156918 tile=necktile;
14991 156918 xofs=0;
14992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14993
14994
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
14995 {
14996 122181 tile+=((clk&24)>>3);
14997 122181 }
14998
14999
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
15000 {
15001 154719 mapscr* scr = get_scr(screen_spawned);
15002
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15003 737 sprite::drawcloaked(dest);
15004 else
15005 153982 sprite::draw(dest);
15006 154719 }
15007 156918 }
15008
15009
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
15010 533 {
15011
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
15012
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
15013 // dummy_bool[0]=false;
15014 533 timer=0;
15015 /* fixing */
15016 533 hp=1000;
15017
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
15018 533 item_set=0;
15019
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
15020
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
15021 533 hxofs=4;
15022 533 hit_width=8;
15023
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15024 533 clk2=clk; // how int32_t to wait before moving first time
15025 533 clk=0;
15026 533 mainguy=count_enemy=false;
15027
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
15028 533 clk3=((dir&2)>>1)+2; // left or right
15029 533 dir&=1; // up or down
15030
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
15031 533 isCore = false;
15032
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
15033
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
15034 {
15035 2132 nxoffset[i] = 0;
15036 2132 nyoffset[i] = 0;
15037
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15038
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15039 2132 }
15040
15041 533 necktile=0;
15042 //TODO compatibility? -DD
15043 /*
15044 for(int32_t i=0; i<4; i++)
15045 {
15046 nx[i]=124;
15047 ny[i]=i*6+48;
15048 }*/
15049 533 bgsfx=-1;
15050 //no need for deadsfx
15051 533 }
15052
15053 515535 bool esGleeok::animate(int32_t index)
15054 {
15055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
15056 // don't call removearmos() - it's a segment.
15057
15058 515535 dmisc5=vbound(dmisc5,1,255);
15059
15060
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
15061 {
15062 402762 x = (xoffset+parent->x);
15063 402762 y = (yoffset+parent->y);
15064
15065
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
15066 {
15067 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15068 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15069 1611048 }
15070 402762 }
15071
15072 // set up the head tiles
15073 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15074 /*
15075 if (dummy_bool[0]) //if this is a flame gleeok
15076 {
15077 headtile+=180;
15078 }
15079 */
15080 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15081 515535 flyingheadtile=dummy_int[3];
15082
15083 // set up the neck tiles
15084 515535 necktile=dummy_int[1];
15085
15086
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
15087 {
15088 402833 necktile+=((clk&24)>>3);
15089 402833 }
15090
15091 /*
15092 else
15093 {
15094 necktile=145;
15095 }
15096 */
15097 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15098
15099
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
15100 {
15101 case 0: // live head
15102 // set up the attached head tiles
15103 402762 tile=headtile;
15104
15105
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15106 {
15107 319820 tile+=((clk&24)>>3);
15108 /*
15109 if (dummy_bool[0]) {
15110 tile+=1561;
15111 }
15112 */
15113 319820 }
15114
15115 /*
15116 else
15117 {
15118 tile=146;
15119 }
15120 */
15121
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15122 {
15123
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15124
15125
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15126
15127
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15128 {
15129 292 dir^=1;
15130 292 }
15131
15132 92832 zfix tempx = x;
15133 92832 zfix tempy = y;
15134
15135 92832 sprite::move(step);
15136 92832 xoffset += (x-tempx);
15137 92832 yoffset += (y-tempy);
15138
15139
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15140 {
15141 3863 clk3^=1;
15142 3863 clk2=-4;
15143 3863 }
15144 else
15145 {
15146
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15147 {
15148 978 clk3=right;
15149 978 }
15150
15151
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15152 {
15153 961 clk3=left;
15154 961 }
15155
15156
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15157 {
15158 3713 clk3^=1; // x jig
15159 3713 }
15160 else
15161 {
15162
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15163 {
15164 851 clk3^=1; // x switch back
15165 851 }
15166
15167 85256 clk2=-4;
15168 }
15169 }
15170
15171 92832 zc_swap(dir,clk3);
15172 92832 tempx = x;
15173 92832 tempy = y;
15174 92832 sprite::move(step);
15175 92832 xoffset += (x-tempx);
15176 92832 yoffset += (y-tempy);
15177 92832 zc_swap(dir,clk3);
15178
15179
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15180 {
15181 278496 nxoffset[i] = (zc_oldrand()%3);
15182 278496 nyoffset[i] = (zc_oldrand()%3);
15183 278496 }
15184 92832 }
15185
15186 402762 break;
15187
15188 case 1: // flying head
15189
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15190
15191 {
15192 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15193 105482 }
15194
15195 112071 break;
15196
15197 // the following are messages sent from the main guy...
15198 case -1: // got chopped off
15199 {
15200 300 misc=1;
15201 300 superman=1;
15202 300 hxofs=xofs=0;
15203 300 hit_width=16;
15204 300 cs=8;
15205 300 clk=-24;
15206 300 clk2=40;
15207 300 dir=(zc_oldrand()&7)+8;
15208 300 step=8.0/9.0;
15209 }
15210 300 break;
15211
15212 case -2: // the big guy is dead
15213 402 return true;
15214 }
15215
15216
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
15217 {
15218
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
15219 {
15220 4791 FireBreath(true);
15221 4791 }
15222
15223 40125 --timer;
15224 40125 }
15225
15226 515133 return enemy::animate(index);
15227 515535 }
15228
15229 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15230 {
15231
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15232 {
15233 int32_t wpnId = w->id;
15234
15235 if(dying)
15236 return 0;
15237
15238 switch(wpnId)
15239 {
15240 case wLitBomb:
15241 case wLitSBomb:
15242 case wBait:
15243 case wWhistle:
15244 case wFire:
15245 case wWind:
15246 case wSSparkle:
15247 case wFSparkle:
15248 case wPhantom:
15249 return 0;
15250
15251 case wHookshot:
15252 case wBrang:
15253 case wBeam:
15254 case wArrow:
15255 case wMagic:
15256 case wBomb:
15257 case wSBomb:
15258 sfx(WAV_CHINK,pan(int32_t(x)));
15259 break;
15260 default:
15261 break;
15262 }
15263
15264 return 1;
15265 }
15266 else
15267 {
15268 7080 int32_t ret = enemy::takehit(w,realweap);
15269
15270
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
15271 5655 return 2; // force it to wait a frame before checking sword attacks again
15272
15273 1425 return ret;
15274 }
15275 7080 }
15276
15277 521456 void esGleeok::draw(BITMAP *dest)
15278 {
15279 521456 dmisc5=vbound(dmisc5,1,255);
15280
15281
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
15282 {
15283 case 0: //neck
15284
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
15285 {
15286
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15287 {
15288 1227318 mapscr* scr = get_scr(screen_spawned);
15289
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
15290 {
15291
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15292 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15293 else
15294 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15295 978198 }
15296 else
15297 {
15298
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15299 overtilecloaked16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15300 else
15301 249120 overtile16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15302 }
15303 1227318 }
15304 409106 }
15305
15306 409106 break;
15307
15308 case 1: //flying head
15309 112350 tile=flyingheadtile;
15310
15311
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
15312 {
15313 82692 tile+=((clk&24)>>3);
15314 82692 break;
15315 }
15316 29658 }
15317 521456 }
15318
15319 521456 void esGleeok::draw2(BITMAP *dest)
15320 {
15321 521456 enemy::draw(dest);
15322 521456 }
15323
15324 190 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15325 190 {
15326
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ( !(editorflags & ENEMY_FLAG5) )
15327 {
15328
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 x = 128;
15329
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 y = 48;
15330 190 }
15331 else { x = X; y = Y; }
15332 190 adjusted=false;
15333
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 dir=(zc_oldrand()&7)+8;
15334 //step=0.25;
15335 190 flycnt=dmisc1;
15336 190 flycnt2=dmisc2;
15337 190 loopcnt=0;
15338 190 clk4 = 0;
15339 190 clk5 = 0;
15340 190 clk6 = 0;
15341 190 clk7 = 0;
15342
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc29 == 0)
15344 {
15345
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15346 {
15347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
15348 105 else dmisc29 = (84 / 3);
15349 105 }
15350 else
15351 {
15352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc29 = (90 / 2);
15353 85 else dmisc29 = (84 / 2);
15354 }
15355 190 }
15356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc30 == 0)
15357 {
15358
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15359 {
15360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15361 105 else dmisc30 = (84 / 3)*0.5;
15362 105 }
15363 else
15364 {
15365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15366 85 else dmisc30 = (84 / 2)*0.5;
15367 }
15368 190 }
15369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc31 == 0)
15370 {
15371
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15372 {
15373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
15374 105 else dmisc31 = (84 / 3)*2;
15375 105 }
15376 else
15377 {
15378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15379 85 else dmisc31 = (84 / 2)*0.5;
15380 }
15381 190 }
15382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc32 == 0)
15383 {
15384
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15385 {
15386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
15387 105 else dmisc32 = (84 / 3);
15388 105 }
15389 else
15390 {
15391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15392 85 else dmisc32 = (84 / 2)*0.25;
15393 }
15394 190 }
15395
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 init_size_flags();
15396 190 }
15397
15398 161885 bool ePatra::animate(int32_t index)
15399 {
15400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161885 times.
161885 if(switch_hooked) return enemy::animate(index);
15401
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 160441 times.
161885 if(dying)
15402 {
15403
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1444 times.
1516 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15404 {
15405 72 ((enemy*)guys.spr(i))->hp = -1000;
15406 72 }
15407
15408 1444 return Dead(index);
15409 }
15410
15411 160441 double basesize = 84;
15412
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc10) basesize = 90;
15413 160441 double halfsize = basesize / 2;
15414 160441 double quartersize = halfsize / 2;
15415 160441 double twothirdsize = (basesize / 3)*2;
15416 160441 double onethirdsize = (basesize / 3);
15417
15418
15419
2/2
✓ Branch 0 taken 123507 times.
✓ Branch 1 taken 36934 times.
160441 if(clk==0)
15420 {
15421 36934 removearmos(x,y,ffcactivated);
15422 36934 }
15423
15424
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160441 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160441 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15425 {
15426
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160441 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15427
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (loopcnt < 0) ++clk2;
15428
2/2
✓ Branch 0 taken 158644 times.
✓ Branch 1 taken 1797 times.
160441 if(++clk2>basesize)
15429 {
15430 1797 clk2=0;
15431
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1797 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1797 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15432 {
15433
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 865 times.
1797 if(loopcnt > 0)
15434 932 --loopcnt;
15435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if (loopcnt == 0)
15436 {
15437
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 356 times.
865 if((misc%dmisc6)==0)
15438 {
15439
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if (dmisc21 > 0) loopcnt=-dmisc21;
15440 356 else loopcnt=dmisc7;
15441 356 }
15442 865 }
15443 else if (loopcnt == -1) loopcnt=dmisc7;
15444 else ++loopcnt;
15445
15446
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1797 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15447 1797 }
15448 else
15449 {
15450 loopcnt = 0;
15451 misc = 1;
15452 }
15453 1797 }
15454 160441 }
15455
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk4 > 0) --clk4;
15456
15457
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 < 0)
15458 {
15459 if (dmisc5 == 1 || dmisc5 == 3)
15460 {
15461 if (get_qr(qr_NEWENEMYTILES))
15462 {
15463 if (clk7 <= 0 || clk6 != -16) ++clk6;
15464 if (clk6 == 0) o_tile=d->e_tile;
15465 else
15466 {
15467 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15468 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15469 }
15470 }
15471 else clk6 = 0;
15472 }
15473 }
15474
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk6;
15475
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk5 < 0) ++clk5;
15476
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk5;
15477
15478
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160441 if (clk7 > 0 && clk6 >= -16) --clk7;
15479
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 > 0) clk7 = 0;
15480
15481
2/2
✓ Branch 0 taken 660384 times.
✓ Branch 1 taken 160441 times.
820825 for(int32_t i=index+1; i<index+flycnt+1; i++)
15482 {
15483 //outside ring
15484
2/2
✓ Branch 0 taken 659040 times.
✓ Branch 1 taken 1344 times.
660384 if(!adjusted)
15485 {
15486
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 192 times.
1344 if(get_qr(qr_NEWENEMYTILES))
15487 {
15488 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15489 1152 enemy *s = ((enemy*)guys.spr(i));
15490 1152 s->parent_uid = this->getUID();
15491 1152 }
15492 else
15493 {
15494 192 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15495 192 enemy *s = ((enemy*)guys.spr(i));
15496 192 s->parent_uid = this->getUID();
15497 }
15498
15499 1344 ((enemy*)guys.spr(i))->cs=dmisc9;
15500 1344 ((enemy*)guys.spr(i))->hp=dmisc3;
15501 1344 }
15502
15503
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 659620 times.
660384 if(((enemy*)guys.spr(i))->hp <= 0)
15504 {
15505
2/2
✓ Branch 0 taken 2889 times.
✓ Branch 1 taken 764 times.
3653 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15506 {
15507 2889 guys.swap(j,j+1);
15508 2889 }
15509
15510
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 670 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
764 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15511 764 }
15512 else
15513 {
15514 659620 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15515
1/2
✓ Branch 0 taken 659620 times.
✗ Branch 1 not taken.
659620 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15516
15517
2/2
✓ Branch 0 taken 212037 times.
✓ Branch 1 taken 447583 times.
659620 if(!dmisc4) //Big Ring
15518 {
15519 //maybe playing_field_offset here?
15520
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
15521 {
15522
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15523
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15524 237330 }
15525 else
15526 {
15527 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15528 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15529 }
15530
15531 447583 temp_x=guys.spr(i)->x;
15532 447583 temp_y=guys.spr(i)->y;
15533 447583 }
15534 else //Oval
15535 {
15536 212037 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15537 212037 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15538
15539
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90996 times.
212037 if(loopcnt>0)
15540 {
15541 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15542
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15543 121041 }
15544 else
15545 {
15546 90996 guys.spr(i)->x = circle_x;
15547 90996 guys.spr(i)->y = circle_y;
15548 }
15549
15550 212037 temp_x=circle_x;
15551 212037 temp_y=circle_y;
15552 }
15553
15554 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15555 659620 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15556
15557
4/4
✓ Branch 0 taken 124008 times.
✓ Branch 1 taken 535612 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83117 times.
659620 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15558 {
15559 83117 guys.spr(i)->dir=l_down;
15560 83117 }
15561
4/4
✓ Branch 0 taken 124459 times.
✓ Branch 1 taken 452044 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83568 times.
576503 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15562 {
15563 83568 guys.spr(i)->dir=left;
15564 83568 }
15565
4/4
✓ Branch 0 taken 123345 times.
✓ Branch 1 taken 369590 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82454 times.
492935 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15566 {
15567 82454 guys.spr(i)->dir=l_up;
15568 82454 }
15569
4/4
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 287402 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82188 times.
410481 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15570 {
15571 82188 guys.spr(i)->dir=up;
15572 82188 }
15573
4/4
✓ Branch 0 taken 122491 times.
✓ Branch 1 taken 205802 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81600 times.
328293 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15574 {
15575 81600 guys.spr(i)->dir=r_up;
15576 81600 }
15577
4/4
✓ Branch 0 taken 122884 times.
✓ Branch 1 taken 123809 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81993 times.
246693 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15578 {
15579 81993 guys.spr(i)->dir=right;
15580 81993 }
15581
4/4
✓ Branch 0 taken 122590 times.
✓ Branch 1 taken 42110 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81699 times.
164700 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15582 {
15583 81699 guys.spr(i)->dir=r_down;
15584 81699 }
15585 else
15586 {
15587 83001 guys.spr(i)->dir=down;
15588 }
15589
15590 659620 guys.spr(i)->x += x;
15591 659620 guys.spr(i)->y += y;
15592 }
15593 660384 }
15594
15595
7/22
✓ Branch 0 taken 106957 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106957 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
160441 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15596 {
15597 32331 int timeneeded = 48;
15598 32331 int patbreath = (zc_oldrand()%50+50);
15599
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
15600
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
15601 {
15602 timeneeded = 48 + patbreath;
15603 }
15604
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
15605 {
15606 timeneeded = 48 + 96;
15607 }
15608
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
15609
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
15610
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15611 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
15612 249 && (clk6 >= 0) //if not in the middle of firing...
15613 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
15614
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
15615 {
15616
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
15617 {
15618 case patratSTREAM:
15619 {
15620 clk7 = 97;
15621 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15622 else clk6 = 0;
15623 break;
15624 }
15625 case patratBREATH:
15626 {
15627 clk7 = patbreath;
15628 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15629 else clk6 = 0;
15630 break;
15631 }
15632 default:
15633 {
15634
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15635 {
15636 clk6 = -48;
15637 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15638 }
15639 else
15640 {
15641 249 clk6 = 0;
15642
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15643 249 FirePatraWeapon();
15644 }
15645 249 break;
15646 }
15647 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15648 249 }
15649
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
15650 {
15651 switch(dmisc28)
15652 {
15653 case patratSTREAM:
15654 {
15655 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
15656 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15657 break;
15658 }
15659 case patratBREATH:
15660 {
15661 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
15662 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15663 break;
15664 }
15665 default:
15666 {
15667 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
15668 {
15669 FirePatraWeapon();
15670 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15671 }
15672 break;
15673 }
15674 }
15675 }
15676 32331 }
15677
15678 160441 int randattempts = 0;
15679 160441 int randeye = 0;
15680
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if (flycnt2 > 0)
15681 {
15682 46240 do
15683 {
15684
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
15685 46240 randeye += (index + flycnt + 1);
15686 46240 ++randattempts;
15687
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
15688 46240 }
15689 160441 bool dofire = false;
15690
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc20)
15691 {
15692 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15693 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
15694 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
15695 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
15696 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
15697 {
15698 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15699 {
15700 if (clk5 >= dmisc19)
15701 {
15702 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15703 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
15704 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
15705 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
15706 || dmisc18 == -1)
15707 dofire = true;
15708 }
15709 }
15710 }
15711 }
15712
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if(flycnt2)
15713 {
15714
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
15715 {
15716
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
15717 {
15718 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
15719
15720
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
15721 {
15722
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15723 {
15724
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
15725 {
15726 // Center eye shoots projectiles; make room for its firing tiles
15727 case 1:
15728 case 3:
15729 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
15730 144 break;
15731
15732 // Center eyes does not shoot; use tiles two rows below for inner eyes.
15733 default:
15734 case 2:
15735 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
15736 168 break;
15737 }
15738 312 }
15739 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
15740 312 }
15741 else
15742 {
15743 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15744 }
15745
15746 312 ((enemy*)guys.spr(i))->cs=dmisc9;
15747
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
15748 312 }
15749
15750
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
15751 {
15752 263816 ((enemy*)guys.spr(i))->superman=true;
15753 263816 }
15754 else
15755 {
15756 70613 ((enemy*)guys.spr(i))->superman=false;
15757 }
15758
15759
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
15760 {
15761
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15762 {
15763 269 guys.swap(j,j+1);
15764 269 }
15765
15766
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
15767 145 }
15768 else
15769 {
15770 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15771
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
15772
15773
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
15774 {
15775
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
15776 {
15777
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15778
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15779 168378 }
15780 else
15781 {
15782 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15783 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15784 }
15785
15786 327025 temp_x=guys.spr(i)->x;
15787 327025 temp_y=guys.spr(i)->y;
15788 327025 }
15789 else
15790 {
15791 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15792 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15793
15794
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
15795 {
15796 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15797
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
15798 3965 }
15799 else
15800 {
15801 3294 guys.spr(i)->x = circle_x;
15802 3294 guys.spr(i)->y = circle_y;
15803 }
15804
15805 7259 temp_x=circle_x;
15806 7259 temp_y=circle_y;
15807 }
15808
15809 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15810 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15811
15812
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15813 {
15814 41746 guys.spr(i)->dir=l_down;
15815 41746 }
15816
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15817 {
15818 41734 guys.spr(i)->dir=left;
15819 41734 }
15820
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15821 {
15822 41742 guys.spr(i)->dir=l_up;
15823 41742 }
15824
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15825 {
15826 41758 guys.spr(i)->dir=up;
15827 41758 }
15828
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15829 {
15830 41830 guys.spr(i)->dir=r_up;
15831 41830 }
15832
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15833 {
15834 41824 guys.spr(i)->dir=right;
15835 41824 }
15836
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15837 {
15838 41852 guys.spr(i)->dir=r_down;
15839 41852 }
15840 else
15841 {
15842 41798 guys.spr(i)->dir=down;
15843 }
15844
15845 334284 guys.spr(i)->x += x;
15846 334284 guys.spr(i)->y = y-guys.spr(i)->y;
15847
15848
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
15849 {
15850 /*
15851 if(!(zc_oldrand()&127))
15852 {
15853 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
15854 sfx(wpnsfx(wpn),pan(int32_t(x)));
15855 }
15856 */
15857
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
15858 {
15859 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
15860 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15861 {
15862 if (dmisc5 == 3)
15863 {
15864 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15865 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
15866 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
15867 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15868 }
15869 else
15870 {
15871 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15872 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15873 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
15874 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15875 }
15876 }
15877 else
15878 {
15879 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15880 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
15881 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
15882 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15883 }
15884 }
15885
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
15886
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
15887
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
15888 {
15889
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
15890 {
15891 case 4: //Single one rapidfires
15892 {
15893 if (dofire && i == randeye)
15894 {
15895 ((esPatra*)guys.spr(i))->clk5 = -16;
15896 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
15897 ((esPatra*)guys.spr(i))->clk4 = 96;
15898 clk5 = -3;
15899 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15900 }
15901 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
15902 {
15903 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15904 sfx(wpnsfx(wpn),pan(int32_t(x)));
15905 }
15906 break;
15907 }
15908 case 3: //Ring
15909 {
15910 if (dofire)
15911 {
15912 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15913 {
15914 ((esPatra*)guys.spr(i))->clk5 = -48;
15915 clk5 = -48;
15916 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15917 }
15918 else
15919 {
15920 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15921 sfx(wpnsfx(wpn),pan(int32_t(x)));
15922 int32_t m=Ewpns.Count()-1;
15923 weapon *ew = (weapon*)(Ewpns.spr(m));
15924
15925 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15926 ((esPatra*)guys.spr(i))->clk5 = 0;
15927 clk5 = 0;
15928 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15929 }
15930 }
15931 if (((esPatra*)guys.spr(i))->clk5 == -16)
15932 {
15933 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15934 sfx(wpnsfx(wpn),pan(int32_t(x)));
15935 int32_t m=Ewpns.Count()-1;
15936 weapon *ew = (weapon*)(Ewpns.spr(m));
15937
15938 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15939 }
15940 break;
15941 }
15942 case 2: //one after another
15943 {
15944 if (dofire)
15945 {
15946 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
15947 clk5 = -48 - (12*flycnt2);
15948 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15949 }
15950 if (((esPatra*)guys.spr(i))->clk5 == -16)
15951 {
15952 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15953 sfx(wpnsfx(wpn),pan(int32_t(x)));
15954 }
15955 break;
15956 }
15957 case 1: //random one eye
15958 {
15959 if (dofire && i == randeye)
15960 {
15961 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15962 {
15963 ((esPatra*)guys.spr(i))->clk5 = -48;
15964 clk5 = -48;
15965 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15966 }
15967 else
15968 {
15969 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15970 sfx(wpnsfx(wpn),pan(int32_t(x)));
15971 ((esPatra*)guys.spr(i))->clk5 = 0;
15972 clk5 = 0;
15973 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15974 }
15975 }
15976 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15977 {
15978 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15979 sfx(wpnsfx(wpn),pan(int32_t(x)));
15980 }
15981 break;
15982 }
15983 default: //old behavior, all eyes can fire any time
15984 {
15985
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15986
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15987
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15988 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
15989 {
15990
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15991 {
15992 ((esPatra*)guys.spr(i))->clk5 = -48;
15993 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15994 }
15995 else
15996 {
15997 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15998 1155 sfx(wpnsfx(wpn),pan(int32_t(x)));
15999 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
16000
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16001 }
16002 1155 }
16003
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16004 {
16005 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16006 sfx(wpnsfx(wpn),pan(int32_t(x)));
16007 }
16008 145268 break;
16009 }
16010 }
16011 145268 }
16012 145268 }
16013
16014 }
16015 334429 }
16016 46240 }
16017
16018 160441 adjusted=true;
16019 160441 return enemy::animate(index);
16020 161885 }
16021
16022 249 void ePatra::FirePatraWeapon()
16023 { //.707
16024 249 int32_t xoff = 0;
16025 249 int32_t yoff = 0;
16026
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_WIDTH)
16027 {
16028 xoff += hxofs;
16029 if (weapoverrideFLAGS & OVERRIDE_HIT_WIDTH)
16030 xoff += (hit_width / 2) - (weap_tilew * 8);
16031 else
16032 xoff += (hit_width / 2) - 8;
16033 }
16034
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
16035 {
16036 yoff += hyofs;
16037 if (weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT)
16038 yoff += (hit_height / 2) - (weap_tileh * 8);
16039 else
16040 yoff += (hit_height / 2) - 8;
16041 }
16042 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16043 // TODO(crash): check that .add succeeds.
16044
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
16045 {
16046 case patrat8SHOT: //Fire Wizzrobe
16047 case patrat4SHOTDIAG:
16048 case patrat4SHOTRAND:
16049 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16050 {
16051 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16052 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16053 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16054 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16055
16056 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16057 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16058 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16059 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16060
16061 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16062 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16063 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16064 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16065
16066 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16067 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16068 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16069 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16070
16071 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16072 }
16073
16074 [[fallthrough]];
16075 case patrat4SHOTCARD: //Stalfos 3
16076 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16077 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16078 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16079 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16080 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16081 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16082 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16083 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16084 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16085 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16086 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16087 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16088 break;
16089
16090 default:
16091 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16092
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16093 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16094
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16095
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16096 {
16097 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16098 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16099 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16100 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16101 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16102 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16103 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16104 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16105 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16106 {
16107 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16108 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16109 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16110 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16111 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16112 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16113 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16114 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16115 }
16116 }
16117 249 break;
16118
16119 }
16120 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16121 //+0.46364761
16122 //11.80
16123 249 }
16124
16125 324242 void ePatra::draw(BITMAP *dest)
16126 {
16127 324242 tile=o_tile;
16128 324242 update_enemy_frame();
16129 324242 enemy::draw(dest);
16130 324242 }
16131
16132 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16133 {
16134 int32_t ret = enemy::defend(wpnId, power, edef);
16135
16136 if(ret < 0 && (flycnt||flycnt2))
16137 return 0;
16138
16139 return ret;
16140 }
16141
16142 1733 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16143 {
16144 1733 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16145
16146
6/6
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 332 times.
1733 if(ret < 0 && (flycnt||flycnt2))
16147 1281 return 0;
16148
16149 452 return ret;
16150 1733 }
16151
16152 190 void ePatra::init_size_flags() {
16153 190 SIZEflags = d->SIZEflags;
16154
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16155
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16156 // al_trace("Enemy txsz:%i\n", txsz);
16157
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16158
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16159
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16160
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hit_width = 32;
16161
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16164
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hxofs = -8;
16165
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16166 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16168
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) xofs = -8;
16169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16170 {
16171 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16172 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16173 }
16174
1/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16175
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (editorflags & ENEMY_FLAG8) misc = 1;
16176
16177
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16178
16179 190 }
16180
16181 3312 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16182 1656 {
16183 //cs=8;
16184 1656 item_set=0;
16185 1656 misc=clk;
16186 1656 clk4 = 0;
16187 1656 clk5 = 0;
16188 1656 clk = -((misc*21)>>1)-1;
16189
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16190 1656 hit_width=12;
16191 1656 hit_height=12;
16192 1656 hxofs=2;
16193 1656 hyofs=2;
16194 1656 extend = 0;
16195 1656 txsz = 1;
16196 1656 tysz = 1;
16197 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16198 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16199 int32_t prntSIZEflags = prntenemy->SIZEflags;
16200 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16201 // al_trace("Enemy txsz:%i\n", txsz);
16202 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16203 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16204 else
16205 hxsz=12;
16206 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16207 else
16208 hysz=12;
16209 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16210 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16211 else
16212 hxofs=2;
16213 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16214 else hyofs=2;
16215 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16216 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16217 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16218 {
16219 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16220 }
16221
16222 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16223 */
16224 1656 mainguy=count_enemy=false;
16225 1656 bgsfx=-1;
16226 //o_tile=0;
16227
2/4
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 flags &= (~guy_never_return);
16228 1656 deadsfx = WAV_EDEAD;
16229 1656 hitsfx = WAV_EHIT;
16230 1656 isCore = false;
16231 1656 }
16232
16233 1010584 bool esPatra::animate(int32_t index)
16234 {
16235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1010584 times.
1010584 if(switch_hooked) return enemy::animate(index);
16236
2/2
✓ Branch 0 taken 15160 times.
✓ Branch 1 taken 995424 times.
1010584 if(dying)
16237 15160 return Dead(index);
16238
16239 995424 return enemy::animate(index);
16240 1010584 }
16241
16242 2028196 void esPatra::draw(BITMAP *dest)
16243 {
16244
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 306902 times.
2028196 if(get_qr(qr_NEWENEMYTILES))
16245 {
16246 1721294 tile = o_tile+(clk&3);
16247
16248
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
16249 {
16250 case up: //u
16251 214278 flip=0;
16252 214278 break;
16253
16254 case down: //d
16255 217924 flip=0;
16256 217924 tile+=4;
16257 217924 break;
16258
16259 case left: //l
16260 215346 flip=0;
16261 215346 tile+=8;
16262 215346 break;
16263
16264 case right: //r
16265 215726 flip=0;
16266 215726 tile+=12;
16267 215726 break;
16268
16269 case l_up: //ul
16270 213062 flip=0;
16271 213062 tile+=20;
16272 213062 break;
16273
16274 case r_up: //ur
16275 214350 flip=0;
16276 214350 tile+=24;
16277 214350 break;
16278
16279 case l_down: //dl
16280 215734 flip=0;
16281 215734 tile+=28;
16282 215734 break;
16283
16284 case r_down: //dr
16285 214874 flip=0;
16286 214874 tile+=32;
16287 214874 break;
16288 }
16289 1721294 }
16290 else
16291 {
16292 306902 tile = o_tile+((clk&2)>>1);
16293 }
16294
16295
2/2
✓ Branch 0 taken 114856 times.
✓ Branch 1 taken 1913340 times.
2028196 if(clk>=0)
16296 1913340 enemy::draw(dest);
16297 2028196 }
16298
16299
16300 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16301 102 {
16302 102 adjusted=false;
16303
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16304
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16305 102 clk4 = 0;
16306 102 clk5 = 0;
16307 //flycnt=6; flycnt2=0;
16308 102 flycnt=dmisc1;
16309 102 flycnt2=0; // PatraBS doesn't have inner rings!
16310 102 loopcnt=0;
16311
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16313
16314 //nets+4480;
16315 102 }
16316
16317 35963 bool ePatraBS::animate(int32_t index)
16318 {
16319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16320
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16321 240 return Dead(index);
16322
16323
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16324 {
16325 4018 removearmos(x,y,ffcactivated);
16326 4018 }
16327
16328 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16329
16330
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16331 {
16332 336 clk2=0;
16333
16334
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16335 177 --loopcnt;
16336 else
16337 {
16338
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if((misc%dmisc6)==0)
16339 84 loopcnt=dmisc7;
16340 }
16341
16342 336 ++misc;
16343 336 }
16344
16345 // double size=1;;
16346
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16347 {
16348
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16349 {
16350 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16351
16352
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16353 {
16354 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16355 612 }
16356 else
16357 {
16358 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16359 }
16360
16361 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16362 612 }
16363
16364
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16365 {
16366
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16367 {
16368 131 guys.swap(j,j+1);
16369 131 }
16370
16371 104 --flycnt;
16372 104 }
16373 else
16374 {
16375 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16376
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16377 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16378 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16379
16380
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16381 {
16382 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16383
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16384 77643 }
16385 else
16386 {
16387 75725 guys.spr(i)->x = temp_x;
16388 75725 guys.spr(i)->y = temp_y;
16389 }
16390
16391 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16392 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16393
16394
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16395 {
16396 18812 guys.spr(i)->dir=l_down;
16397 18812 }
16398
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16399 {
16400 18839 guys.spr(i)->dir=left;
16401 18839 }
16402
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16403 {
16404 18802 guys.spr(i)->dir=l_up;
16405 18802 }
16406
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16407 {
16408 20143 guys.spr(i)->dir=up;
16409 20143 }
16410
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16411 {
16412 18517 guys.spr(i)->dir=r_up;
16413 18517 }
16414
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16415 {
16416 18779 guys.spr(i)->dir=right;
16417 18779 }
16418
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16419 {
16420 18992 guys.spr(i)->dir=r_down;
16421 18992 }
16422 else
16423 {
16424 20484 guys.spr(i)->dir=down;
16425 }
16426
16427 153368 guys.spr(i)->x += x;
16428 153368 guys.spr(i)->y += y;
16429 }
16430 153472 }
16431
16432 35723 adjusted=true;
16433 35723 return enemy::animate(index);
16434 35963 }
16435
16436 72874 void ePatraBS::draw(BITMAP *dest)
16437 {
16438 72874 tile=o_tile;
16439
16440
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16441 {
16442 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16443 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16444
16445
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16446 {
16447 19146 lookat=l_down;
16448 19146 }
16449
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16450 {
16451 18298 lookat=down;
16452 18298 }
16453
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16454 {
16455 13624 lookat=r_down;
16456 13624 }
16457
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16458 {
16459 7492 lookat=right;
16460 7492 }
16461
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16462 {
16463 1170 lookat=r_up;
16464 1170 }
16465
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16466 {
16467 964 lookat=up;
16468 964 }
16469
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16470 {
16471 1700 lookat=l_up;
16472 1700 }
16473 else
16474 {
16475 10480 lookat=left;
16476 }
16477
16478
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16479 {
16480 case up: //u
16481 964 flip=0;
16482 964 break;
16483
16484 case down: //d
16485 18298 flip=0;
16486 18298 tile+=8;
16487 18298 break;
16488
16489 case left: //l
16490 10480 flip=0;
16491 10480 tile+=40;
16492 10480 break;
16493
16494 case right: //r
16495 7492 flip=0;
16496 7492 tile+=48;
16497 7492 break;
16498
16499 case l_up: //ul
16500 1700 flip=0;
16501 1700 tile+=80;
16502 1700 break;
16503
16504 case r_up: //ur
16505 1170 flip=0;
16506 1170 tile+=88;
16507 1170 break;
16508
16509 case l_down: //dl
16510 19146 flip=0;
16511 19146 tile+=120;
16512 19146 break;
16513
16514 case r_down: //dr
16515 13624 flip=0;
16516 13624 tile+=128;
16517 13624 break;
16518 }
16519
16520 72874 tile+=(2*(clk&3));
16521 72874 xofs-=8;
16522 72874 yofs-=8;
16523 72874 drawblock(dest,15);
16524 72874 xofs+=8;
16525 72874 yofs+=8;
16526 72874 }
16527 else
16528 {
16529 flip=(clk&1);
16530 xofs-=8;
16531 yofs-=8;
16532 enemy::draw(dest);
16533 xofs+=16;
16534 enemy::draw(dest);
16535 yofs+=16;
16536 enemy::draw(dest);
16537 xofs-=16;
16538 enemy::draw(dest);
16539 xofs+=8;
16540 yofs-=8;
16541 }
16542 72874 }
16543
16544 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16545 {
16546 int32_t ret = enemy::defend(wpnId, power, edef);
16547
16548 if(ret < 0 && (flycnt||flycnt2))
16549 return 0;
16550
16551 return ret;
16552 }
16553
16554 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16555 {
16556 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16557
16558
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16559 81 return 0;
16560
16561 61 return ret;
16562 142 }
16563
16564 102 void ePatraBS::init_size_flags()
16565 {
16566 102 SIZEflags = d->SIZEflags;
16567
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16568 // al_trace("Enemy txsz:%i\n", txsz);
16569
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16570
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16571 102 else hit_width = 32;
16572
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16573
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16575 102 else hxofs = -8;
16576
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16577 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16578
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16579
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16580 {
16581 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16582 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16583 }
16584
16585
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16586 102 }
16587
16588 1224 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16589 612 {
16590 //cs=csBOSS;
16591 612 item_set=0;
16592 612 misc=clk;
16593 612 clk = -((misc*21)>>1)-1;
16594 612 clk4 = 0;
16595 612 clk5 = 0;
16596
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16597 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16598
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16599 // al_trace("Enemy txsz:%i\n", txsz);
16600
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16601
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16602 612 else hit_width=16;
16603
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
16604 612 else hit_height=16;
16605
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16606
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16608 612 else hyofs=2;
16609 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16610
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
16612 {
16613 yofs = (int32_t)prntenemy->yofs;
16614 }
16615
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16616
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
16617
16618 612 bgsfx=-1;
16619 612 mainguy=count_enemy=false;
16620 612 deadsfx = WAV_EDEAD;
16621 612 hitsfx = WAV_EHIT;
16622
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
16623 612 isCore = false;
16624 612 }
16625
16626 155090 bool esPatraBS::animate(int32_t index)
16627 {
16628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
16629
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
16630 1552 return Dead(index);
16631
16632 153538 return enemy::animate(index);
16633 155090 }
16634
16635 315868 void esPatraBS::draw(BITMAP *dest)
16636 {
16637 315868 tile=o_tile;
16638
16639
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
16640 {
16641
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
16642 {
16643 case up: //u
16644 41612 flip=0;
16645 41612 break;
16646
16647 case down: //d
16648 42622 flip=0;
16649 42622 tile+=4;
16650 42622 break;
16651
16652 case left: //l
16653 37916 flip=0;
16654 37916 tile+=8;
16655 37916 break;
16656
16657 case right: //r
16658 38458 flip=0;
16659 38458 tile+=12;
16660 38458 break;
16661
16662 case l_up: //ul
16663 38564 flip=0;
16664 38564 tile+=20;
16665 38564 break;
16666
16667 case r_up: //ur
16668 38568 flip=0;
16669 38568 tile+=24;
16670 38568 break;
16671
16672 case l_down: //dl
16673 38662 flip=0;
16674 38662 tile+=28;
16675 38662 break;
16676
16677 case r_down: //dr
16678 39466 flip=0;
16679 39466 tile+=32;
16680 39466 break;
16681 }
16682
16683 315868 tile += ((clk&6)>>1);
16684 315868 }
16685 else
16686 {
16687 tile += (clk&4)?1:0;
16688 }
16689
16690
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
16691 283752 enemy::draw(dest);
16692 315868 }
16693
16694 242293 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
16695 {
16696
4/6
✓ Branch 0 taken 135715 times.
✓ Branch 1 taken 106578 times.
✓ Branch 2 taken 135715 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135715 times.
✗ Branch 5 not taken.
242293 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
16697
4/8
✓ Branch 0 taken 242293 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242293 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242293 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242293 times.
✗ Branch 7 not taken.
242293 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
16698
1/2
✓ Branch 0 taken 242293 times.
✗ Branch 1 not taken.
242293 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16699 242293 }
16700
16701 74709 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
16702 {
16703 // Kludge
16704
4/8
✓ Branch 0 taken 74709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74709 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74709 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74709 times.
✗ Branch 7 not taken.
74709 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
16705 74709 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
16706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74709 times.
74709 delete w;
16707 74709 return ret;
16708 }
16709
16710 9213 void enemy_scored(int32_t index)
16711 {
16712 9213 ((enemy*)guys.spr(index))->scored=true;
16713 9213 }
16714
16715 2191 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
16716 {
16717
5/8
✓ Branch 0 taken 2191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 279 times.
✓ Branch 5 taken 1912 times.
✓ Branch 6 taken 2191 times.
✗ Branch 7 not taken.
2191 guy *g = new guy((zfix)x,(zfix)y,id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
16718
2/2
✓ Branch 0 taken 1426 times.
✓ Branch 1 taken 765 times.
2191 if (isdungeon(g->screen_spawned))
16719 765 g->y += 1;
16720
5/6
✓ Branch 0 taken 1277 times.
✓ Branch 1 taken 914 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1273 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2191 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
16721 {
16722 4 g->o_tile = parentscr->guytile;
16723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
16724 4 g->flags &= ~guy_invisible;
16725 4 g->cs = parentscr->guycs;
16726 4 }
16727 2191 guys.add(g);
16728 2191 }
16729
16730 23700 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16731 {
16732
4/8
✓ Branch 0 taken 23700 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23700 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23700 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23700 times.
✗ Branch 7 not taken.
23700 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
16733 23700 items.add(i);
16734 23700 }
16735
16736 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
16737 {
16738
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
16739 150 items.add(i);
16740 150 }
16741
16742 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16743 {
16744
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
16745 3 items.add(i);
16746 3 }
16747
16748 19319 void add_item_for_screen(int32_t screen, item* item)
16749 {
16750 19319 item->screen_spawned = screen;
16751 19319 items.add(item);
16752 19319 }
16753
16754 96 void kill_em_all()
16755 {
16756
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 96 times.
449 for(int32_t i=0; i<guys.Count(); i++)
16757 {
16758 353 enemy *e = ((enemy*)guys.spr(i));
16759
16760
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
353 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
16761
16762 323 e->kickbucket();
16763 323 }
16764 96 }
16765
16766 bool can_kill_em_all()
16767 {
16768 for(int32_t i=0; i<guys.Count(); i++)
16769 {
16770 enemy *e = ((enemy*)guys.spr(i));
16771
16772 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
16773 if(e->superman) continue;
16774 return true;
16775 }
16776 return false;
16777 }
16778
16779 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
16780 // For Hero's hit detection. Don't count them if they are stunned or are guys.
16781 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16782 {
16783 for(int32_t i=0; i<guys.Count(); i++)
16784 {
16785 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16786 {
16787 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
16788 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
16789 {
16790 return i;
16791 }
16792 }
16793 }
16794
16795 return -1;
16796 }
16797
16798 13136585 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16799 {
16800
4/4
✓ Branch 0 taken 16511 times.
✓ Branch 1 taken 13120074 times.
✓ Branch 2 taken 33792255 times.
✓ Branch 3 taken 13105824 times.
46898079 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
16801 {
16802
2/2
✓ Branch 0 taken 30761 times.
✓ Branch 1 taken 33761494 times.
33792255 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16803 {
16804 30761 return i;
16805 }
16806 33761494 }
16807
16808 13105824 return -1;
16809 13136585 }
16810
16811 // For Hero's hit detection. Count them if they are dying.
16812 52508 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16813 {
16814 52508 enemy *e = (enemy*)guys.spr(index);
16815
3/4
✓ Branch 0 taken 52508 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28055 times.
✓ Branch 3 taken 24453 times.
52508 if(!e || e->hp > 0)
16816 28055 return -1;
16817
16818 24453 bool d = e->dying;
16819 24453 int32_t hc = e->hclk;
16820 24453 e->dying = false;
16821 24453 e->hclk = 0;
16822 24453 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
16823 24453 e->dying = d;
16824 24453 e->hclk = hc;
16825
16826
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 24296 times.
24453 return hit ? index : -1;
16827 52508 }
16828
16829 14653842 bool hasMainGuy(int screen)
16830 {
16831
2/2
✓ Branch 0 taken 15971000 times.
✓ Branch 1 taken 5938543 times.
21909543 for(int32_t i=0; i<guys.Count(); i++)
16832 {
16833 15971000 enemy* e = (enemy*)guys.spr(i);
16834
4/4
✓ Branch 0 taken 15507166 times.
✓ Branch 1 taken 463834 times.
✓ Branch 2 taken 8715299 times.
✓ Branch 3 taken 6791867 times.
15971000 if (e->screen_spawned == screen && e->mainguy)
16835 {
16836 8715299 return true;
16837 }
16838 7255701 }
16839
16840 5938543 return false;
16841 14653842 }
16842
16843 138 void EatHero(int32_t index)
16844 {
16845 138 ((eStalfos*)guys.spr(index))->eathero();
16846 138 }
16847
16848 9 void GrabHero(int32_t index)
16849 {
16850 9 ((eWallM*)guys.spr(index))->grabhero();
16851 9 }
16852
16853 1338 bool CarryHero()
16854 {
16855
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
16856 {
16857
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->family==eeWALLM)
16858 {
16859
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
16860 {
16861 1338 Hero.x=guys.spr(i)->x;
16862 1338 Hero.y=guys.spr(i)->y;
16863 1338 return ((eWallM*)guys.spr(i))->misc > 0;
16864 }
16865 505 }
16866
16867 // Like Likes currently can't carry Hero.
16868 /*
16869 if(((guy*)(guys.spr(i)))->family==eeLIKE)
16870 {
16871 if(((eLikeLike*)guys.spr(i))->hashero)
16872 {
16873 Hero.x=guys.spr(i)->x;
16874 Hero.y=guys.spr(i)->y;
16875 return (true);
16876 }
16877 }*/
16878 2595 }
16879
16880 return false;
16881 1338 }
16882
16883 // Move item with guy
16884 void movefairy(zfix &x,zfix &y,int32_t misc)
16885 {
16886 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16887
16888 if(i!=-1)
16889 {
16890 x = guys.spr(i)->x;
16891 y = guys.spr(i)->y;
16892 }
16893 }
16894
16895 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16896 void movefairy2(zfix x,zfix y,int32_t misc)
16897 {
16898 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16899
16900 if(i!=-1)
16901 {
16902 guys.spr(i)->x = x;
16903 guys.spr(i)->y = y;
16904 }
16905 }// Move item with guy
16906
16907 60788 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
16908 {
16909 60788 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16910
16911
1/2
✓ Branch 0 taken 60788 times.
✗ Branch 1 not taken.
60788 if(fairy)
16912 {
16913 60788 x = fairy->x;
16914 60788 y = fairy->y;
16915 60788 }
16916 60788 }
16917
16918 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16919 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
16920 {
16921 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16922
16923
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
16924 {
16925 404 fairy->x = x;
16926 404 fairy->y = y;
16927 404 }
16928 404 }
16929
16930 void killfairy(int32_t misc)
16931 {
16932 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16933 guys.del(i);
16934 }
16935
16936 219 int32_t getGuyIndex(const int32_t eid)
16937 {
16938
1/2
✓ Branch 0 taken 828 times.
✗ Branch 1 not taken.
828 for(word i = 0; i < guys.Count(); i++)
16939 {
16940
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 609 times.
828 if(guys.spr(i)->getUID() == eid)
16941 219 return i;
16942 609 }
16943
16944 return -1;
16945 219 }
16946
16947 219 void killfairynew(item const &itemfairy)
16948 {
16949 219 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16950
1/2
✓ Branch 0 taken 219 times.
✗ Branch 1 not taken.
219 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
16951 219 }
16952
16953 //Should probably change this to return an 'enemy*', null on failure -Em
16954 21819 int32_t addenemy(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk)
16955 {
16956 21819 return addenemy_z(screen,x,y,0,id,clk);
16957 }
16958
16959 1965 int32_t addchild(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_uid)
16960 {
16961 1965 return addchild_z(screen,x,y,0,id,clk, parent_uid);
16962 }
16963
16964 1997 int32_t addchild_z(int32_t screen, int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_uid)
16965 {
16966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
16967
16968 1997 int32_t ret = 0;
16969 1997 sprite *e=NULL;
16970 1997 al_trace("Adding child\n");
16971
16972
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].family)
16973 {
16974 //Fixme: possible enemy memory leak. (minor)
16975 case eeWALK:
16976
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
16977 110 break;
16978
16979 case eeLEV:
16980 e = new eLeever((zfix)x,(zfix)y,id,clk);
16981 break;
16982
16983 case eeTEK:
16984 e = new eTektite((zfix)x,(zfix)y,id,clk);
16985 break;
16986
16987 case eePEAHAT:
16988 e = new ePeahat((zfix)x,(zfix)y,id,clk);
16989 break;
16990
16991 case eeZORA:
16992 e = new eZora((zfix)x,(zfix)y,id,clk);
16993 break;
16994
16995 case eeGHINI:
16996 e = new eGhini((zfix)x,(zfix)y,id,clk);
16997 break;
16998
16999 case eeKEESE:
17000
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
17001 1865 break;
17002
17003 case eeWIZZ:
17004
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17005 15 break;
17006
17007 case eePROJECTILE:
17008 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17009 break;
17010
17011 case eeWALLM:
17012 e = new eWallM((zfix)x,(zfix)y,id,clk);
17013 break;
17014
17015 case eeAQUA:
17016 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17017 break;
17018
17019 case eeMOLD:
17020 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17021 break;
17022
17023 case eeMANHAN:
17024
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17025 1 break;
17026
17027 case eeGLEEOK:
17028 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17029 break;
17030
17031 case eeGHOMA:
17032 e = new eGohma((zfix)x,(zfix)y,id,clk);
17033 break;
17034
17035 case eeLANM:
17036 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17037 break;
17038
17039 case eeGANON:
17040 e = new eGanon((zfix)x,(zfix)y,id,clk);
17041 break;
17042
17043 case eeFAIRY:
17044 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17045 break;
17046
17047 case eeFIRE:
17048
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
17049 2 break;
17050
17051 case eeOTHER:
17052 e = new eOther((zfix)x,(zfix)y,id,clk);
17053 break;
17054
17055
17056 case eeSCRIPT01:
17057 case eeSCRIPT02:
17058 case eeSCRIPT03:
17059 case eeSCRIPT04:
17060 case eeSCRIPT05:
17061 case eeSCRIPT06:
17062 case eeSCRIPT07:
17063 case eeSCRIPT08:
17064 case eeSCRIPT09:
17065 case eeSCRIPT10:
17066 case eeSCRIPT11:
17067 case eeSCRIPT12:
17068 case eeSCRIPT13:
17069 case eeSCRIPT14:
17070 case eeSCRIPT15:
17071 case eeSCRIPT16:
17072 case eeSCRIPT17:
17073 case eeSCRIPT18:
17074 case eeSCRIPT19:
17075 case eeSCRIPT20:
17076 {
17077 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17078 {
17079 e = new eScript((zfix)x,(zfix)y,id,clk);
17080 break;
17081 }
17082 else return 0;
17083 }
17084
17085 case eeFFRIENDLY01:
17086 case eeFFRIENDLY02:
17087 case eeFFRIENDLY03:
17088 case eeFFRIENDLY04:
17089 case eeFFRIENDLY05:
17090 case eeFFRIENDLY06:
17091 case eeFFRIENDLY07:
17092 case eeFFRIENDLY08:
17093 case eeFFRIENDLY09:
17094 case eeFFRIENDLY10:
17095 {
17096 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17097 {
17098 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17099 }
17100 else return 0;
17101
17102 }
17103
17104 case eeSPINTILE:
17105 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17106 break;
17107
17108 // and these enemies use the misc10/misc2 value
17109 case eeROCK:
17110 {
17111 switch(guysbuf[id&0xFFF].attributes[9])
17112 {
17113 case 1:
17114 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17115 break;
17116
17117 case 0:
17118 default:
17119 e = new eRock((zfix)x,(zfix)y,id,clk);
17120 break;
17121 }
17122
17123 break;
17124 }
17125
17126 case eeTRAP:
17127 {
17128 switch(guysbuf[id&0xFFF].attributes[1])
17129 {
17130 case 1:
17131 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17132 break;
17133
17134 case 0:
17135 default:
17136 e = new eTrap((zfix)x,(zfix)y,id,clk);
17137 break;
17138 }
17139
17140 break;
17141 }
17142
17143 case eeDONGO:
17144 {
17145 switch(guysbuf[id&0xFFF].attributes[9])
17146 {
17147 case 1:
17148 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17149 break;
17150
17151 case 0:
17152 default:
17153 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17154 break;
17155 }
17156
17157 break;
17158 }
17159
17160 case eeDIG:
17161 {
17162
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17163 {
17164 case 1:
17165 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17166 break;
17167
17168 4 case 0:
17169 default:
17170
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17171 4 break;
17172 }
17173
17174 4 break;
17175 }
17176
17177 case eePATRA:
17178 {
17179 switch(guysbuf[id&0xFFF].attributes[9])
17180 {
17181 case 1:
17182 if (get_qr(qr_HARDCODED_BS_PATRA))
17183 {
17184 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17185 break;
17186 }
17187 [[fallthrough]];
17188 case 0:
17189 default:
17190 e = new ePatra((zfix)x,(zfix)y,id,clk);
17191 break;
17192 }
17193
17194 break;
17195 }
17196
17197 case eeGUY:
17198 {
17199 switch(guysbuf[id&0xFFF].attributes[9])
17200 {
17201 case 1:
17202 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17203 break;
17204
17205 case 0:
17206 default:
17207 e = new eNPC((zfix)x,(zfix)y,id,clk);
17208 break;
17209 }
17210
17211 break;
17212 }
17213
17214 case eeNONE:
17215 if(guysbuf[id&0xFFF].attributes[9] ==1)
17216 {
17217 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17218 break;
17219 break;
17220 }
17221 [[fallthrough]];
17222 default:
17223
17224 return 0;
17225 }
17226
17227 1997 ret++; // Made one enemy.
17228
17229
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17230 {
17231 7 e->z = (zfix)z;
17232 7 }
17233
17234
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17235 1997 ((enemy*)e)->parent_uid = parent_uid;
17236
17237
17238
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17239 {
17240 return 0;
17241 }
17242
17243 // add segments of segmented enemies
17244 1997 int32_t c=0;
17245
17246
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].family)
17247 {
17248 case eeMOLD:
17249 {
17250 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17251 id &= 0xFFF;
17252
17253 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17254 {
17255 //christ this is messy -DD
17256 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17257
17258 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17259 {
17260 al_trace("Moldorm segment %d could not be created!\n",i+1);
17261
17262 for(int32_t j=0; j<i+1; j++)
17263 guys.del(guys.Count()-1);
17264
17265 return 0;
17266 }
17267
17268 if(i>0)
17269 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17270
17271 ret++;
17272 }
17273
17274 break;
17275 }
17276
17277 case eeLANM:
17278 {
17279 id &= 0xFFF;
17280 int32_t shft = guysbuf[id].attributes[1];
17281 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17282
17283 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17284 {
17285 al_trace("Lanmola segment 1 could not be created!\n");
17286 guys.del(guys.Count()-1);
17287 return 0;
17288 }
17289
17290 ret++;
17291
17292 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17293 {
17294 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17295 {
17296 al_trace("Lanmola segment %d could not be created!\n",i+1);
17297
17298 for(int32_t j=0; j<i+1; j++)
17299 guys.del(guys.Count()-1);
17300
17301 return 0;
17302 }
17303
17304 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17305 ret++;
17306 }
17307 }
17308 break;
17309
17310 case eeMANHAN:
17311 1 id &= 0xFFF;
17312
17313
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17314 {
17315
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17316 {
17317 al_trace("Manhandla head %d could not be created!\n",i+1);
17318
17319 for(int32_t j=0; j<i+1; j++)
17320 {
17321 guys.del(guys.Count()-1);
17322 }
17323
17324 return 0;
17325 }
17326
17327 4 ret++;
17328 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17329 4 }
17330
17331 1 break;
17332
17333 case eeGLEEOK:
17334 {
17335 id &= 0xFFF;
17336
17337 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17338 {
17339 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17340 {
17341 al_trace("Gleeok head %d could not be created!\n",i+1);
17342
17343 for(int32_t j=0; j<i+1; j++)
17344 {
17345 guys.del(guys.Count()-1);
17346 }
17347
17348 return false;
17349 }
17350
17351 c-=guysbuf[id].attributes[3];
17352 ret++;
17353 }
17354 }
17355 break;
17356
17357
17358 case eePATRA:
17359 {
17360 id &= 0xFFF;
17361 int32_t outeyes = 0;
17362
17363 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17364 {
17365 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17366 {
17367 al_trace("Patra outer eye %d could not be created!\n",i+1);
17368
17369 for(int32_t j=0; j<i+1; j++)
17370 guys.del(guys.Count()-1);
17371
17372 return 0;
17373 }
17374 else
17375 outeyes++;
17376
17377 ret++;
17378 }
17379
17380 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17381 {
17382 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17383 {
17384 al_trace("Patra inner eye %d could not be created!\n",i+1);
17385
17386 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17387 guys.del(guys.Count()-1);
17388
17389 return 0;
17390 }
17391
17392 ret++;
17393 }
17394
17395 break;
17396 }
17397 }
17398
17399
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 1997 times.
3998 for (int i = 0; i < ret; i++)
17400 {
17401 2001 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17402 2001 e->screen_spawned = screen;
17403 2001 }
17404
17405 1997 return ret;
17406 1997 }
17407
17408 // Returns number of enemies/segments created
17409 102130 int32_t addenemy_z(int32_t screen,int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17410 {
17411 102130 int32_t realid = id&0xFFF;
17412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102130 times.
102130 if( realid > MAXGUYS )
17413 {
17414 return 0;
17415 }
17416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102130 times.
102130 if(id <= 0) return 0;
17417
17418 102130 int32_t ret = 0;
17419 102130 sprite *e=NULL;
17420
17421
28/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50138 times.
✓ Branch 4 taken 3942 times.
✓ Branch 5 taken 5212 times.
✓ Branch 6 taken 1825 times.
✓ Branch 7 taken 2797 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 11855 times.
✓ Branch 10 taken 5335 times.
✓ Branch 11 taken 4429 times.
✓ Branch 12 taken 998 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 732 times.
✓ Branch 21 taken 758 times.
✓ Branch 22 taken 7627 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2472 times.
✓ Branch 26 taken 251 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 292 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
102130 switch(guysbuf[id&0xFFF].family)
17422 {
17423 //Fixme: possible enemy memory leak. (minor)
17424 case eeWALK:
17425
3/6
✓ Branch 0 taken 50138 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50138 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50138 times.
✗ Branch 5 not taken.
50138 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17426 50138 break;
17427
17428 case eeLEV:
17429
3/6
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3942 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3942 times.
✗ Branch 5 not taken.
3942 e = new eLeever((zfix)x,(zfix)y,id,clk);
17430 3942 break;
17431
17432 case eeTEK:
17433
3/6
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5212 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5212 times.
✗ Branch 5 not taken.
5212 e = new eTektite((zfix)x,(zfix)y,id,clk);
17434 5212 break;
17435
17436 case eePEAHAT:
17437
3/6
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
1825 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17438 1825 break;
17439
17440 case eeZORA:
17441
3/6
✓ Branch 0 taken 2797 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2797 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2797 times.
✗ Branch 5 not taken.
2797 e = new eZora((zfix)x,(zfix)y,id,clk);
17442 2797 break;
17443
17444 case eeGHINI:
17445
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
17446 461 break;
17447
17448 case eeKEESE:
17449
3/6
✓ Branch 0 taken 11855 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11855 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11855 times.
✗ Branch 5 not taken.
11855 e = new eKeese((zfix)x,(zfix)y,id,clk);
17450 11855 break;
17451
17452 case eeWIZZ:
17453
3/6
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5335 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5335 times.
✗ Branch 5 not taken.
5335 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17454 5335 break;
17455
17456 case eePROJECTILE:
17457
3/6
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4429 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4429 times.
✗ Branch 5 not taken.
4429 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17458 4429 break;
17459
17460 case eeWALLM:
17461
3/6
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 998 times.
✗ Branch 5 not taken.
998 e = new eWallM((zfix)x,(zfix)y,id,clk);
17462 998 break;
17463
17464 case eeAQUA:
17465
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17466 126 break;
17467
17468 case eeMOLD:
17469
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17470 618 break;
17471
17472 case eeMANHAN:
17473
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17474 149 break;
17475
17476 case eeGLEEOK:
17477
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17478 168 break;
17479
17480 case eeGHOMA:
17481
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17482 93 break;
17483
17484 case eeLANM:
17485
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17486 420 break;
17487
17488 case eeGANON:
17489
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
17490 13 break;
17491
17492 case eeFAIRY:
17493
3/6
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 732 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 732 times.
✗ Branch 5 not taken.
732 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17494 732 break;
17495
17496 case eeFIRE:
17497
3/6
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 758 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 758 times.
✗ Branch 5 not taken.
758 e = new eFire((zfix)x,(zfix)y,id,clk);
17498 758 break;
17499
17500 case eeOTHER:
17501
3/6
✓ Branch 0 taken 7627 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7627 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7627 times.
✗ Branch 5 not taken.
7627 e = new eOther((zfix)x,(zfix)y,id,clk);
17502 7627 break;
17503
17504
17505 case eeSCRIPT01:
17506 case eeSCRIPT02:
17507 case eeSCRIPT03:
17508 case eeSCRIPT04:
17509 case eeSCRIPT05:
17510 case eeSCRIPT06:
17511 case eeSCRIPT07:
17512 case eeSCRIPT08:
17513 case eeSCRIPT09:
17514 case eeSCRIPT10:
17515 case eeSCRIPT11:
17516 case eeSCRIPT12:
17517 case eeSCRIPT13:
17518 case eeSCRIPT14:
17519 case eeSCRIPT15:
17520 case eeSCRIPT16:
17521 case eeSCRIPT17:
17522 case eeSCRIPT18:
17523 case eeSCRIPT19:
17524 case eeSCRIPT20:
17525 {
17526 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17527 {
17528 e = new eScript((zfix)x,(zfix)y,id,clk);
17529 break;
17530 }
17531 else return 0;
17532 }
17533
17534 case eeFFRIENDLY01:
17535 case eeFFRIENDLY02:
17536 case eeFFRIENDLY03:
17537 case eeFFRIENDLY04:
17538 case eeFFRIENDLY05:
17539 case eeFFRIENDLY06:
17540 case eeFFRIENDLY07:
17541 case eeFFRIENDLY08:
17542 case eeFFRIENDLY09:
17543 case eeFFRIENDLY10:
17544 {
17545 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17546 {
17547 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17548 }
17549 else return 0;
17550
17551 }
17552
17553 case eeSPINTILE:
17554
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17555 94 break;
17556
17557 // and these enemies use the misc10/misc2 value
17558 case eeROCK:
17559 {
17560
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17561 {
17562 case 1:
17563
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17564 30 break;
17565
17566 354 case 0:
17567 default:
17568
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17569 354 break;
17570 }
17571
17572 384 break;
17573 }
17574
17575 case eeTRAP:
17576 {
17577
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1640 times.
2472 switch(guysbuf[id&0xFFF].attributes[1])
17578 {
17579 case 1:
17580
3/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
832 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17581 832 break;
17582
17583 1640 case 0:
17584 default:
17585
3/6
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1640 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1640 times.
✗ Branch 5 not taken.
1640 e = new eTrap((zfix)x,(zfix)y,id,clk);
17586 1640 break;
17587 }
17588
17589 2472 break;
17590 }
17591
17592 case eeDONGO:
17593 {
17594
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 203 times.
251 switch(guysbuf[id&0xFFF].attributes[9])
17595 {
17596 case 1:
17597
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17598 48 break;
17599
17600 203 case 0:
17601 default:
17602
3/6
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 203 times.
✗ Branch 5 not taken.
203 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17603 203 break;
17604 }
17605
17606 251 break;
17607 }
17608
17609 case eeDIG:
17610 {
17611
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].attributes[9])
17612 {
17613 case 1:
17614
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17615 327 break;
17616
17617 76 case 0:
17618 default:
17619
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17620 76 break;
17621 }
17622
17623 403 break;
17624 }
17625
17626 case eePATRA:
17627 {
17628
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 102 times.
292 switch(guysbuf[id&0xFFF].attributes[9])
17629 {
17630 case 1:
17631
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
17632 {
17633
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17634 102 break;
17635 }
17636 [[fallthrough]];
17637 190 case 0:
17638 default:
17639
3/6
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
190 e = new ePatra((zfix)x,(zfix)y,id,clk);
17640 190 break;
17641 }
17642
17643 292 break;
17644 }
17645
17646 case eeGUY:
17647 {
17648
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
17649 {
17650 case 1:
17651 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17652 break;
17653
17654 5 case 0:
17655 default:
17656
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
17657 5 break;
17658 }
17659
17660 5 break;
17661 }
17662
17663 case eeNONE:
17664
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].attributes[9] ==1)
17665 {
17666
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17667 533 break;
17668 }
17669 [[fallthrough]];
17670 default:
17671
17672 return 0;
17673 }
17674
17675 102130 ret++; // Made one enemy.
17676
17677
4/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 101953 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 152 times.
102130 if(z && canfall(id))
17678 {
17679 152 e->z = (zfix)z;
17680 152 }
17681
17682
2/2
✓ Branch 0 taken 101953 times.
✓ Branch 1 taken 177 times.
102130 ((enemy*)e)->ceiling = (z && canfall(id));
17683
17684
1/2
✓ Branch 0 taken 102130 times.
✗ Branch 1 not taken.
102130 if(!guys.add(e))
17685 {
17686 return 0;
17687 }
17688
17689 // add segments of segmented enemies
17690 102130 int32_t c=0;
17691
17692
6/6
✓ Branch 0 taken 100483 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 292 times.
102130 switch(guysbuf[id&0xFFF].family)
17693 {
17694 case eeMOLD:
17695 {
17696 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17697 618 id &= 0xFFF;
17698
17699
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17700 {
17701 //christ this is messy -DD
17702 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17703
17704
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17705 {
17706 al_trace("Moldorm segment %d could not be created!\n",i+1);
17707
17708 for(int32_t j=0; j<i+1; j++)
17709 guys.del(guys.Count()-1);
17710
17711 return 0;
17712 }
17713
17714
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
17715 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17716
17717 3150 ret++;
17718 3150 }
17719
17720 618 break;
17721 }
17722
17723 case eeLANM:
17724 {
17725 420 id &= 0xFFF;
17726 420 int32_t shft = guysbuf[id].attributes[1];
17727 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17728
17729
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17730 {
17731 al_trace("Lanmola segment 1 could not be created!\n");
17732 guys.del(guys.Count()-1);
17733 return 0;
17734 }
17735
17736 420 ret++;
17737
17738
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17739 {
17740
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17741 {
17742 al_trace("Lanmola segment %d could not be created!\n",i+1);
17743
17744 for(int32_t j=0; j<i+1; j++)
17745 guys.del(guys.Count()-1);
17746
17747 return 0;
17748 }
17749
17750 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17751 1847 ret++;
17752 1847 }
17753 }
17754 420 break;
17755
17756 case eeMANHAN:
17757 149 id &= 0xFFF;
17758
17759
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17760 {
17761
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17762 {
17763 al_trace("Manhandla head %d could not be created!\n",i+1);
17764
17765 for(int32_t j=0; j<i+1; j++)
17766 {
17767 guys.del(guys.Count()-1);
17768 }
17769
17770 return 0;
17771 }
17772
17773 688 ret++;
17774 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17775 688 }
17776
17777 149 break;
17778
17779 case eeGLEEOK:
17780 {
17781 168 id &= 0xFFF;
17782 168 eGleeok* parent = (eGleeok*)e;
17783
17784
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17785 {
17786
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
17787
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
17788 {
17789 al_trace("Gleeok head %d could not be created!\n",i+1);
17790
17791 for(int32_t j=0; j<i+1; j++)
17792 {
17793 guys.del(guys.Count()-1);
17794 }
17795
17796 return false;
17797 }
17798
17799 533 head->necktile=parent->necktile;
17800 533 head->dummy_int[1]=parent->necktile;
17801
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
17802 {
17803 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
17804 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
17805 421 }
17806 else
17807 {
17808 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
17809 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
17810 }
17811 533 head->tile = head->dummy_int[2];
17812
17813 533 c-=guysbuf[id].attributes[3];
17814 533 ret++;
17815 533 }
17816 }
17817 168 break;
17818
17819
17820 case eePATRA:
17821 {
17822 292 id &= 0xFFF;
17823 292 int32_t outeyes = 0;
17824
17825
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✓ Branch 2 taken 1956 times.
✓ Branch 3 taken 292 times.
2248 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17826 {
17827
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1344 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1344 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1344 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1344 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1956 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17828 {
17829 al_trace("Patra outer eye %d could not be created!\n",i+1);
17830
17831 for(int32_t j=0; j<i+1; j++)
17832 guys.del(guys.Count()-1);
17833
17834 return 0;
17835 }
17836 else
17837 1956 outeyes++;
17838
17839 1956 ret++;
17840 1956 }
17841
17842
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 292 times.
604 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17843 {
17844
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17845 {
17846 al_trace("Patra inner eye %d could not be created!\n",i+1);
17847
17848 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17849 guys.del(guys.Count()-1);
17850
17851 return 0;
17852 }
17853
17854 312 ret++;
17855 312 }
17856
17857 292 break;
17858 }
17859 }
17860
17861
2/2
✓ Branch 0 taken 111036 times.
✓ Branch 1 taken 102130 times.
213166 for (int i = 0; i < ret; i++)
17862 {
17863 111036 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17864 111036 e->screen_spawned = screen;
17865 111036 }
17866
17867 102130 return ret;
17868 102130 }
17869
17870 2035238 bool isjumper(int32_t id)
17871 {
17872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2035238 times.
2035238 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
17873 {
17874 return false;
17875 }
17876
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1929360 times.
✓ Branch 2 taken 105869 times.
2035238 switch(guysbuf[id&0xFFF].family)
17877 {
17878 case eeROCK:
17879 case eeTEK:
17880 9 return true;
17881
17882 case eeWALK:
17883
3/4
✓ Branch 0 taken 105869 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 93604 times.
105869 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
17884 93604 }
17885
17886 2022964 return false;
17887 2035238 }
17888
17889
17890 8068 bool isfixedtogrid(int32_t id)
17891 {
17892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8068 times.
8068 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
17893 {
17894 return false;
17895 }
17896
1/2
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
8068 switch(guysbuf[id&0xFFF].family)
17897 {
17898 case eeWALK:
17899 case eeLEV:
17900 case eeZORA:
17901 case eeDONGO:
17902 case eeGANON:
17903 case eeROCK:
17904 case eeGLEEOK:
17905 case eeAQUA:
17906 case eeLANM:
17907 return true;
17908 }
17909
17910 8068 return false;
17911 8068 }
17912
17913 // Can't fall, can have Z value.
17914 52274583 bool isflier(int32_t id)
17915 {
17916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52274583 times.
52274583 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
17917 {
17918 return false;
17919 }
17920
2/2
✓ Branch 0 taken 45758685 times.
✓ Branch 1 taken 6515898 times.
52274583 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
17921 {
17922 case eePEAHAT:
17923 case eeKEESE:
17924 case eePATRA:
17925 case eeFAIRY:
17926 case eeGHINI:
17927
17928 // Could theoretically have their Z set by a script
17929 case eeFIRE:
17930 6515898 return true;
17931 break;
17932 }
17933
17934 45758685 return false;
17935 52274583 }
17936
17937 // Can't have Z position
17938 3997966 bool never_in_air(int32_t id)
17939 {
17940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3997966 times.
3997966 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
17941 {
17942 return false;
17943 }
17944
2/2
✓ Branch 0 taken 3988416 times.
✓ Branch 1 taken 9550 times.
3997966 switch(guysbuf[id&0xFFF].family)
17945 {
17946 case eeMANHAN:
17947 case eeMOLD:
17948 case eeLANM:
17949 case eeGLEEOK:
17950 case eeZORA:
17951 case eeLEV:
17952 case eeAQUA:
17953 case eeROCK:
17954 case eeGANON:
17955 case eeTRAP:
17956 case eePROJECTILE:
17957 case eeSPINTILE:
17958 9550 return true;
17959 }
17960
17961 3988416 return false;
17962 3997966 }
17963
17964 2224118 bool canfall(int32_t id)
17965 {
17966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2224118 times.
2224118 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
17967 {
17968 return false;
17969 }
17970
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2224078 times.
✓ Branch 2 taken 40 times.
2224118 switch(guysbuf[id&0xFFF].family)
17971 {
17972 case eeGUY:
17973 {
17974
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
17975 40 return false;
17976
17977 switch(guysbuf[id&0xFFF].attributes[9])
17978 {
17979 case 1:
17980 case 2:
17981 return true;
17982
17983 case 0:
17984 case 3:
17985 default:
17986 return false;
17987 }
17988
17989 case eeGHOMA:
17990 case eeDIG:
17991 return false;
17992 }
17993 }
17994
17995
17996
4/4
✓ Branch 0 taken 2215642 times.
✓ Branch 1 taken 8436 times.
✓ Branch 2 taken 180404 times.
✓ Branch 3 taken 2035238 times.
2224078 return !never_in_air(id) && !isflier(id) && !isjumper(id);
17997 2224118 }
17998
17999 73876240 bool enemy::enemycanfall(int32_t id, bool checkgrav)
18000 {
18001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73876240 times.
73876240 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18002 {
18003 return false;
18004 }
18005 //Z_scripterrlog("canfall family is %d:\n", family);
18006 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
18007 //if ( family == eeFIRE && id >= eSTART )
18008 //{
18009 // Z_scripterrlog("eeFire\n");
18010 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
18011 //}
18012
18013 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
18014
18015
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 71367822 times.
✓ Branch 2 taken 2079483 times.
73876240 switch(guysbuf[id&0xFFF].family)
18016 {
18017 case eeGUY:
18018 {
18019
1/2
✓ Branch 0 taken 2079483 times.
✗ Branch 1 not taken.
2079483 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18020 2079483 return false;
18021
18022 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
18023 {
18024 case 1:
18025 case 2:
18026 return true;
18027
18028 case 0:
18029 case 3:
18030 default:
18031 return false;
18032 }
18033
18034 case eeGHOMA:
18035 case eeDIG:
18036 428935 return false;
18037 }
18038 }
18039
18040
2/2
✓ Branch 0 taken 39126140 times.
✓ Branch 1 taken 32241682 times.
71367822 if(!checkgrav) return true;
18041 39126140 return (moveflags & move_obeys_grav);
18042
18043 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18044 // {
18045 // if ( moveflags & move_obeys_grav ) return true;
18046 // else return false;
18047 // }
18048 // else
18049 // {
18050 // return (moveflags & move_obeys_grav);
18051 // }
18052 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18053 73876240 }
18054
18055 1271 void addfires()
18056 {
18057
2/2
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 457 times.
1271 if(!get_qr(qr_NOGUYFIRES))
18058 {
18059 2285 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
18060 457 int32_t bs = get_qr(qr_BSZELDA);
18061 914 addguy(dx+(bs? 64: 72),dy+64,gFIRE,-17,false,nullptr);
18062 914 addguy(dx+(bs?176:168),dy+64,gFIRE,-18,false,nullptr);
18063 457 }
18064 1271 }
18065
18066 // This function runs one time for every screen on the first frame of a region being loaded.
18067 // It handles spawning screen guys (not the enemies), item, and room-specific sprites.
18068 36994 static void loadguys(mapscr* scr)
18069 {
18070 36994 int screen = scr->screen;
18071 36994 byte Guy=0;
18072 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18073 // Else use mITEM and ipONETIME
18074 36994 int32_t mf = (screen>=128) ? mSPECIALITEM : mITEM;
18075 36994 int32_t onetime = (screen>=128) ? ipONETIME2 : ipONETIME;
18076
18077 36994 mapscr* guyscr = scr;
18078
4/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 36088 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 431 times.
36994 if(screen>=128 && DMaps[cur_dmap].flags&dmfGUYCAVES)
18079 {
18080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431 times.
431 if(DMaps[cur_dmap].flags&dmfCAVES)
18081 {
18082 431 Guy=special_warp_return_scr->guy;
18083 431 guyscr = special_warp_return_scr;
18084 431 }
18085 431 }
18086 else
18087 {
18088 36563 Guy=scr->guy;
18089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36563 times.
36563 if (game->get_regionmapping() == REGION_MAPPING_FULL)
18090 36563 mark_visited(screen);
18091 }
18092
18093 113898 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18094
18095 36994 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18096 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18097
4/4
✓ Branch 0 taken 3865 times.
✓ Branch 1 taken 33129 times.
✓ Branch 2 taken 2550 times.
✓ Branch 3 taken 1315 times.
36994 if(Guy && ((screen>=128) == !!(DMaps[cur_dmap].flags&dmfGUYCAVES)))
18098 {
18099
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1304 times.
1315 if(scr->room==rZELDA)
18100 {
18101 22 addguy(dx+120,dy+72,Guy,-15,true,guyscr);
18102 11 guys.spr(0)->hxofs=1000;
18103 33 addenemy(screen,dx+128,dy+96,eFIRE,-15);
18104 33 addenemy(screen,dx+112,dy+96,eFIRE,-15);
18105 33 addenemy(screen,dx+96,dy+120,eFIRE,-15);
18106 33 addenemy(screen,dx+144,dy+120,eFIRE,-15);
18107 11 return;
18108 }
18109
18110
2/2
✓ Branch 0 taken 1300 times.
✓ Branch 1 taken 4 times.
2604 bool ffire = oldguy
18111
2/2
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 29 times.
1300 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18112 4 : (guyscr->roomflags&RFL_GUYFIRES);
18113
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1271 times.
1304 if(ffire)
18114 1271 addfires();
18115
18116
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 425 times.
1304 if(screen>=128)
18117
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
438 if(getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))
18118 13 Guy=0;
18119
18120
4/6
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 1091 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1304 switch(scr->room)
18121 {
18122 case rSP_ITEM:
18123 case rGRUMBLE:
18124 case rBOMBS:
18125 case rARROWS:
18126 case rSWINDLE:
18127 case rMUPGRADE:
18128 case rLEARNSLASH:
18129 case rTAKEONE:
18130
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 42 times.
167 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18131 55 Guy=0;
18132
18133 167 break;
18134
18135 case rREPAIR:
18136 if (get_qr(qr_OLD_DOORREPAIR)) break;
18137 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18138 Guy=0;
18139
18140 break;
18141 case rRP_HC:
18142 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18143 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18144 Guy=0;
18145
18146 break;
18147 case rMONEY:
18148
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18149 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18150 Guy=0;
18151
18152 break;
18153
18154 case rTRIFORCE:
18155 {
18156 45 int32_t tc = TriforceCount();
18157
18158
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18159 {
18160
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18161 10 Guy=0;
18162 9 }
18163 else
18164 {
18165
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18166 33 Guy=0;
18167 }
18168 }
18169 43 break;
18170 }
18171
18172
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1195 times.
1302 if(Guy)
18173 {
18174
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1162 times.
1195 if(ffire)
18175 1162 blockpath=true;
18176
18177
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 783 times.
1195 if(screen<128)
18178 783 sfx(WAV_SCALE);
18179
18180
6/6
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 467 times.
✓ Branch 3 taken 728 times.
✓ Branch 4 taken 110 times.
✓ Branch 5 taken 357 times.
2390 addguy(dx+120,dy+64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true, guyscr);
18181 1195 Hero.Freeze();
18182 1195 }
18183 1302 }
18184
5/6
✓ Branch 0 taken 33886 times.
✓ Branch 1 taken 1793 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 33815 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1793 times.
35679 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18185 {
18186 71 sfx(WAV_SCALE);
18187 142 addguy(dx+120,dy+62,gFAIRY,-14,false,guyscr);
18188 71 }
18189
18190 110943 loaditem(scr, dx, dy);
18191
18192 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18193 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18194
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 36962 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
36981 if (scr->room==r10RUPIES && !getmapflag(screen, mf))
18195 {
18196
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18197 300 additem(dx+ten_rupies_x[i],dy+ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18198 15 }
18199 36992 }
18200
18201 35750 void loadguys()
18202 {
18203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35750 times.
35750 if (loaded_guys)
18204 return;
18205
18206 35750 loaded_guys = true;
18207 35750 repaircharge = 0;
18208 35750 adjustmagic = false;
18209 35750 learnslash = false;
18210
2/2
✓ Branch 0 taken 107250 times.
✓ Branch 1 taken 35750 times.
143000 for (int32_t i=0; i<3; i++)
18211 {
18212 107250 prices[i] = 0;
18213 107250 }
18214
18215 72744 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18216 36994 get_screen_state(scr->screen).item_state = ScreenItemState::None;
18217 36994 loadguys(scr);
18218 36994 });
18219 35750 }
18220
18221 37000 void loaditem(mapscr* scr, int offx, int offy)
18222 {
18223 37000 int screen = scr->screen;
18224 37000 byte Item = 0;
18225
18226
2/2
✓ Branch 0 taken 36094 times.
✓ Branch 1 taken 906 times.
37000 if(screen<128)
18227 {
18228 36094 Item=scr->item;
18229
18230
4/4
✓ Branch 0 taken 1590 times.
✓ Branch 1 taken 34504 times.
✓ Branch 2 taken 32881 times.
✓ Branch 3 taken 3213 times.
36094 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
18231 {
18232
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3154 times.
3213 if(scr->flags8&fSECRETITEM)
18233 59 screen_item_set_state(screen, ScreenItemState::WhenTriggerSecrets);
18234
2/2
✓ Branch 0 taken 1164 times.
✓ Branch 1 taken 1990 times.
3154 else if(scr->flags&fITEM)
18235 1164 screen_item_set_state(screen, ScreenItemState::WhenKillEnemies);
18236
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 1882 times.
1990 else if(scr->flags11&efCARRYITEM)
18237 108 screen_item_set_state(screen, ScreenItemState::MustGiveToEnemy); // Will be set to CarriedByEnemy in roaming_item
18238 else
18239 {
18240 1882 int x = scr->itemx;
18241
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1867 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
1882 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18242 -170 :
18243 1882 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18244
3/6
✓ Branch 0 taken 1882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1882 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1882 times.
✗ Branch 5 not taken.
3764 add_item_for_screen(screen, new item(offx + x, offy + y,
18245
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1867 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1867 times.
✗ Branch 9 not taken.
1882 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18246
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1777 times.
1882 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
18247 1882 (scr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18248 }
18249 3213 }
18250 36094 }
18251
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 475 times.
906 else if(!(DMaps[cur_dmap].flags&dmfCAVES))
18252 {
18253
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag(screen, (screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (special_warp_return_scr->flags9&fBELOWRETURN)) && special_warp_return_scr->room==rSP_ITEM
18254
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (screen==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18255 {
18256 163 Item = special_warp_return_scr->catchall;
18257
18258
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
18259 {
18260 162 int x = scr->itemx;
18261
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18262 -170 :
18263 162 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18264
3/6
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162 times.
✗ Branch 5 not taken.
324 add_item_for_screen(screen, new item(offx + x, offy + y,
18265
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18266 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18267 162 }
18268 163 }
18269 475 }
18270 37000 }
18271
18272 957 void never_return(int32_t screen, int32_t index)
18273 {
18274
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 191 times.
957 if(!get_qr(qr_KILLALL))
18275 191 goto doit;
18276
18277
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 329 times.
2621 for(int32_t i=0; i<guys.Count(); i++)
18278
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 543 times.
✓ Branch 3 taken 437 times.
2292 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18279 {
18280 437 goto dontdoit;
18281 329 }
18282
18283 doit:
18284 520 setmapflag(get_scr(screen), mNEVERRET);
18285 dontdoit:
18286 957 return;
18287 }
18288
18289 63745 bool slowguy(int32_t id)
18290 {
18291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63745 times.
63745 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18292 {
18293 return false;
18294 }
18295 //return (guysbuf[id].step<100);
18296
2/2
✓ Branch 0 taken 54102 times.
✓ Branch 1 taken 9643 times.
63745 switch(id)
18297 {
18298 case eOCTO1S:
18299 case eOCTO2S:
18300 case eOCTO1F:
18301 case eOCTO2F:
18302 case eLEV1:
18303 case eLEV2:
18304 case eROCK:
18305 case eBOULDER:
18306 9643 return true;
18307 }
18308
18309 54102 return false;
18310 63745 }
18311
18312 83355 static bool ok2add(mapscr* scr, int32_t id)
18313 {
18314
2/4
✓ Branch 0 taken 83355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 83355 times.
83355 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
18315 {
18316 return false;
18317 }
18318
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 82526 times.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 365 times.
83355 if(getmapflag(scr, mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18319 464 return false;
18320
18321
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 82250 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 201 times.
82891 switch(guysbuf[id].family)
18322 {
18323 // I added a special case for shooters because having traps on the same screen
18324 // was preventing them from spawning due to TMPNORET. This means they will
18325 // never stay dead, though, so it may not be the best solution. - Saf
18326 case eePROJECTILE:
18327 376 return true;
18328
18329
18330 case eeDIG:
18331 {
18332
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].attributes[9])
18333 {
18334 case 1:
18335
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18336 79 return !getmapflag(scr, mTMPNORET);
18337
18338 47 return true;
18339
18340 75 case 0:
18341 default:
18342 75 return true;
18343 }
18344 }
18345 case eeGANON:
18346 case eeTRAP:
18347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18348
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18349 [[fallthrough]];
18350 default:
18351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82250 times.
82250 if (guysbuf[id].flags&guy_ignoretmpnr) return true;
18352 82250 break;
18353 }
18354
18355
2/2
✓ Branch 0 taken 20977 times.
✓ Branch 1 taken 61273 times.
82250 if(!get_qr(qr_NOTMPNORET))
18356 61273 return !getmapflag(scr, mTMPNORET);
18357
18358 20977 return true;
18359 83355 }
18360
18361 1633743 static void activate_fireball_statue(const rpos_handle_t& rpos_handle)
18362 {
18363
3/4
✓ Branch 0 taken 288841 times.
✓ Branch 1 taken 1344902 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288841 times.
1633743 if (!(rpos_handle.scr->flags11&efFIREBALLS) || statueID<0)
18364 {
18365 1344902 return;
18366 }
18367
18368 288841 int32_t ctype = rpos_handle.ctype();
18369
6/6
✓ Branch 0 taken 287333 times.
✓ Branch 1 taken 1508 times.
✓ Branch 2 taken 286018 times.
✓ Branch 3 taken 1315 times.
✓ Branch 4 taken 1213 times.
✓ Branch 5 taken 284805 times.
288841 if (ctype != cL_STATUE && ctype != cR_STATUE && ctype != cC_STATUE) return;
18370
18371 12108 auto [x, y] = rpos_handle.xy();
18372
18373 4036 int32_t cx=-1000, cy=-1000;
18374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(!isfixedtogrid(statueID))
18375 {
18376
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 2528 times.
4036 if(ctype==cL_STATUE)
18377 {
18378 1508 cx=x+4;
18379 1508 cy=y+7;
18380 1508 }
18381
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 1213 times.
2528 else if(ctype==cR_STATUE)
18382 {
18383 1315 cx=x-8;
18384 1315 cy=y-1;
18385 1315 }
18386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1213 times.
1213 else if(ctype==cC_STATUE)
18387 {
18388 1213 cx=x;
18389 1213 cy=y;
18390 1213 }
18391 4036 }
18392 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18393 {
18394 cx=x;
18395 cy=y;
18396 }
18397
18398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(cx!=-1000) // No point creating it if this is false
18399 {
18400
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
18401 {
18402
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18403 {
18404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18405 4 return; // No point deleting it. A script might be toying with it in some way.
18406 else
18407 guys.del(j);
18408 }
18409 9750 }
18410
18411 4032 addenemy(rpos_handle.screen, cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18412 4032 }
18413 1633743 }
18414
18415 34351 static void activate_fireball_statues(mapscr* scr)
18416 {
18417
2/2
✓ Branch 0 taken 32932 times.
✓ Branch 1 taken 1419 times.
34351 if (!(scr->flags11&efFIREBALLS))
18418 {
18419 32932 return;
18420 }
18421
18422 251163 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18423 249744 activate_fireball_statue(rpos_handle);
18424 249744 });
18425 34351 }
18426
18427 35034 void load_default_enemies(mapscr* scr)
18428 {
18429 35034 int screen = scr->screen;
18430 40499 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18431
18432 35034 wallm_load_clk=frame-80;
18433
18434
2/2
✓ Branch 0 taken 33138 times.
✓ Branch 1 taken 1896 times.
35034 if(scr->flags11&efZORA)
18435 {
18436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1896 times.
1896 if(zoraID>=0)
18437 5688 addenemy(screen, dx - 16, dy - 16, zoraID, 0);
18438 1896 }
18439
18440
2/2
✓ Branch 0 taken 34856 times.
✓ Branch 1 taken 178 times.
35034 if(scr->flags11&efTRAP4)
18441 {
18442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
18443 {
18444 534 addenemy(screen, dx + 32, dy + 32, cornerTrapID, -14);
18445 534 addenemy(screen, dx + 208, dy + 32, cornerTrapID, -14);
18446 534 addenemy(screen, dx + 32, dy + 128, cornerTrapID, -14);
18447 534 addenemy(screen, dx + 208, dy + 128, cornerTrapID, -14);
18448 178 }
18449 178 }
18450
18451 6201018 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18452 6165984 int32_t ctype = rpos_handle.ctype();
18453 6165984 int32_t cflag = rpos_handle.sflag();
18454 6165984 int32_t cflag_i = rpos_handle.cflag();
18455
18456
4/6
✓ Branch 0 taken 6165984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6165638 times.
✓ Branch 3 taken 346 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6165638 times.
6165984 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18457 {
18458 346 auto [x, y] = rpos_handle.xy();
18459
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 336 times.
346 if(trapLOSHorizontalID>=0)
18460 1008 addenemy(screen, x, y, trapLOSHorizontalID, -14);
18461 346 }
18462
4/6
✓ Branch 0 taken 6165638 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6165432 times.
✓ Branch 3 taken 206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6165432 times.
6165638 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18463 {
18464 206 auto [x, y] = rpos_handle.xy();
18465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(trapLOSVerticalID>=0)
18466 618 addenemy(screen, x, y, trapLOSVerticalID, -14);
18467 206 }
18468
4/6
✓ Branch 0 taken 6165432 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6165154 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6165154 times.
6165432 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18469 {
18470 278 auto [x, y] = rpos_handle.xy();
18471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18472 {
18473
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 278 times.
834 if(addenemy(screen, x, y, trapLOS4WayID, -14))
18474 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18475 278 }
18476 278 }
18477
4/6
✓ Branch 0 taken 6165154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6164755 times.
✓ Branch 3 taken 399 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6164755 times.
6165154 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18478 {
18479 399 auto [x, y] = rpos_handle.xy();
18480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(trapConstantHorizontalID>=0)
18481 1197 addenemy(screen, x, y, trapConstantHorizontalID, -14);
18482 399 }
18483
4/6
✓ Branch 0 taken 6164755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6164322 times.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6164322 times.
6164755 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18484 {
18485 433 auto [x, y] = rpos_handle.xy();
18486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(trapConstantVerticalID>=0)
18487 1299 addenemy(screen, x, y, trapConstantVerticalID, -14);
18488 433 }
18489
18490
1/2
✓ Branch 0 taken 6165984 times.
✗ Branch 1 not taken.
6165984 if(ctype==cSPINTILE1)
18491 {
18492 awaken_spinning_tile(rpos_handle);
18493 }
18494 6165984 });
18495
18496
2/2
✓ Branch 0 taken 34978 times.
✓ Branch 1 taken 56 times.
35034 if(scr->flags11&efTRAP2)
18497 {
18498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
18499 {
18500
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 64, 80, centerTrapID, -14))
18501 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18502
18503
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 176, 80, centerTrapID, -14))
18504 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18505 56 }
18506 56 }
18507
18508
2/2
✓ Branch 0 taken 34951 times.
✓ Branch 1 taken 83 times.
35034 if(scr->flags11&efROCKS)
18509 {
18510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18511 {
18512 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18513 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18514 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18515 83 }
18516 83 }
18517 35034 }
18518
18519 #define SLOPE_STAGE_COMBOS 0
18520 #define SLOPE_STAGE_FFCS 1
18521 #define SLOPE_STAGE_COMBOS_BORDERING_SCREENS 2
18522
18523 20766529 static slope_id_t create_slope_id(int stage, int arg1, int arg2)
18524 {
18525
2/2
✓ Branch 0 taken 4593074 times.
✓ Branch 1 taken 16173455 times.
20766529 if (stage == SLOPE_STAGE_COMBOS)
18526 16173455 return (region_num_rpos*arg1)+arg2;
18527
2/2
✓ Branch 0 taken 4451942 times.
✓ Branch 1 taken 141132 times.
4593074 if (stage == SLOPE_STAGE_FFCS)
18528 4451942 return (region_num_rpos*7)+arg1;
18529
1/2
✓ Branch 0 taken 141132 times.
✗ Branch 1 not taken.
141132 if (stage == SLOPE_STAGE_COMBOS_BORDERING_SCREENS)
18530 141132 return (region_num_rpos*7 + MAX_FFCID+1)+arg1*7*(16 * 2 + 11 * 2) + arg2;
18531 // TODO: what about FFCs from bordering screens?
18532
18533 assert(false);
18534 return 0;
18535 20766529 }
18536
18537 16173455 void update_slope_combopos(const rpos_handle_t& rpos_handle)
18538 {
18539 16173455 mapscr* s = rpos_handle.scr;
18540 16173455 auto& cmb = rpos_handle.combo();
18541
18542 16173455 auto id = create_slope_id(SLOPE_STAGE_COMBOS, rpos_handle.layer, (int)rpos_handle.rpos);
18543 16173455 auto it = slopes.find(id);
18544
18545 16173455 bool wasSlope = it!=slopes.end();
18546 16173455 bool isSlope = cmb.type == cSLOPE;
18547
18548
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 16173319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
16173455 if(isSlope && !wasSlope)
18549 {
18550 272 auto [x, y] = rpos_handle.xy();
18551 272 slopes.try_emplace(id, &(s->data[rpos_handle.pos]), nullptr, -1, x, y);
18552 136 }
18553
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16173319 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16173319 else if(wasSlope && !isSlope)
18554 {
18555 slopes.erase(it);
18556 }
18557 16173455 }
18558
18559 141132 static void update_slope_combopos_bordering_screen(int dir, int slope_count, int cid, bool is_slope, int offx, int offy)
18560 {
18561 141132 auto id = create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS, dir, slope_count);
18562 141132 auto it = slopes.find(id);
18563
18564 141132 bool wasSlope = it!=slopes.end();
18565 141132 bool isSlope = is_slope;
18566
18567
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 141132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
141132 if(isSlope && !wasSlope)
18568 {
18569 static std::vector<word> TMP;
18570 int num_border_combos = cur_region.screen_width*16 * 2 + cur_region.screen_height*11 * 2;
18571 TMP.resize(num_border_combos * 7 * 4);
18572
18573 int tmp_index = id-create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS,0,0);
18574 TMP[tmp_index] = cid;
18575 slopes.try_emplace(id, &TMP[tmp_index], nullptr, -1, offx, offy);
18576 }
18577
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 141132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
141132 else if(wasSlope && !isSlope)
18578 {
18579 slopes.erase(it);
18580 }
18581 141132 }
18582
18583 // Load a single column or row from a nearby screen, and load its slopes.
18584 3880 static void handle_slope_combopos_bordering_screen(int initial_screen, int dir)
18585 {
18586 55806 auto [map, screen] = nextscr2(cur_map, initial_screen, dir);
18587
2/2
✓ Branch 0 taken 3709 times.
✓ Branch 1 taken 171 times.
3880 if (map == -1)
18588 171 return;
18589
18590 3709 int offx = 0;
18591 3709 int offy = 0;
18592
2/2
✓ Branch 0 taken 2797 times.
✓ Branch 1 taken 912 times.
3709 if (dir == up)
18593 912 offy = -16;
18594
2/2
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 1936 times.
2797 else if (dir == down)
18595 861 offy = world_h;
18596
2/2
✓ Branch 0 taken 967 times.
✓ Branch 1 taken 969 times.
1936 else if (dir == left)
18597 967 offx = -16;
18598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 969 times.
969 else if (dir == right)
18599 969 offx = world_w;
18600
18601
2/2
✓ Branch 0 taken 3709 times.
✓ Branch 1 taken 25963 times.
29672 for (int layer = 0; layer < 7; layer++)
18602 {
18603 51926 auto scr = load_temp_mapscr_and_apply_secrets(map, screen, layer - 1, true, false);
18604
2/2
✓ Branch 0 taken 10522 times.
✓ Branch 1 taken 15441 times.
25963 if (!scr) continue;
18605
18606 10522 int slope_count = layer * (16*2);
18607
18608
4/4
✓ Branch 0 taken 7822 times.
✓ Branch 1 taken 2700 times.
✓ Branch 2 taken 2744 times.
✓ Branch 3 taken 5078 times.
10522 if (dir == left || dir == right)
18609 {
18610 5444 int x = dir == left ? 15 : 0;
18611
2/2
✓ Branch 0 taken 59884 times.
✓ Branch 1 taken 5444 times.
65328 for (int y = 0; y < 11; y++)
18612 {
18613 59884 int pos = y * 16 + x;
18614 59884 int cid = scr->data[pos];
18615 59884 bool is_slope = combobuf[cid].type == cSLOPE;
18616
1/2
✓ Branch 0 taken 59884 times.
✗ Branch 1 not taken.
59884 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx, offy + y*16);
18617 59884 }
18618 5444 }
18619
3/4
✓ Branch 0 taken 2437 times.
✓ Branch 1 taken 2641 times.
✓ Branch 2 taken 2437 times.
✗ Branch 3 not taken.
5078 else if (dir == up || dir == down)
18620 {
18621 5078 int y = dir == up ? 10 : 0;
18622
2/2
✓ Branch 0 taken 81248 times.
✓ Branch 1 taken 5078 times.
86326 for (int x = 0; x < 16; x++)
18623 {
18624 81248 int pos = y * 16 + x;
18625 81248 int cid = scr->data[pos];
18626 81248 bool is_slope = combobuf[cid].type == cSLOPE;
18627
1/2
✓ Branch 0 taken 81248 times.
✗ Branch 1 not taken.
81248 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx + x*16, offy);
18628 81248 }
18629 5078 }
18630
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15441 times.
✓ Branch 2 taken 10522 times.
25963 }
18631 3880 }
18632
18633 35828 void update_slope_comboposes()
18634 {
18635 14825284 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18636 14789456 update_slope_combopos(rpos_handle);
18637 14789456 });
18638
18639
2/2
✓ Branch 0 taken 34858 times.
✓ Branch 1 taken 970 times.
35828 if (Hero.sideview_mode())
18640 {
18641 1940 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18642
2/2
✓ Branch 0 taken 3880 times.
✓ Branch 1 taken 970 times.
4850 for (int dir = up; dir <= right; dir++)
18643 3880 handle_slope_combopos_bordering_screen(scr->screen, dir);
18644 970 });
18645 970 }
18646
18647 35828 update_slopes();
18648 35828 }
18649
18650 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
18651 1383999 void screen_combo_modify_preroutine(const rpos_handle_t& rpos_handle)
18652 {
18653 1383999 delete_fireball_shooter(rpos_handle);
18654 1383999 }
18655
18656 //Placeholder in case we need it.
18657 void screen_ffc_modify_preroutine(const ffc_handle_t& ffc_handle)
18658 {
18659 return;
18660 }
18661
18662 // Everything that must be done after we change a screen's combo to another combo. -L
18663 1383999 void screen_combo_modify_postroutine(const rpos_handle_t& rpos_handle)
18664 {
18665 1383999 rpos_handle.scr->valid |= mVALID;
18666 1383999 activate_fireball_statue(rpos_handle);
18667
18668
2/2
✓ Branch 0 taken 1383905 times.
✓ Branch 1 taken 94 times.
1383999 if(rpos_handle.ctype()==cSPINTILE1)
18669 {
18670 94 awaken_spinning_tile(rpos_handle);
18671 94 }
18672
18673 1383999 update_slope_combopos(rpos_handle);
18674 1383999 }
18675
18676 4451942 void screen_ffc_modify_postroutine(const ffc_handle_t& ffc_handle)
18677 {
18678 4451942 ffcdata* ff = ffc_handle.ffc;
18679 4451942 auto& cmb = ffc_handle.combo();
18680
18681 4451942 auto id = create_slope_id(SLOPE_STAGE_FFCS, ffc_handle.id, -1);
18682 4451942 auto it = slopes.find(id);
18683
18684 4451942 bool wasSlope = it!=slopes.end();
18685
1/2
✓ Branch 0 taken 4451942 times.
✗ Branch 1 not taken.
4451942 bool isSlope = cmb.type == cSLOPE && !(ff->flags&ffc_changer);
18686
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4451942 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4451942 if(isSlope && !wasSlope)
18687 {
18688 slopes.try_emplace(id, nullptr, ff, ffc_handle.id);
18689 }
18690
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4451942 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4451942 else if(wasSlope && !isSlope)
18691 {
18692 slopes.erase(it);
18693 }
18694
18695 4451942 ffc_handle.scr->ffcCountMarkDirty();
18696 4451942 }
18697
18698 4406 void screen_combo_modify_pre(int32_t cid)
18699 {
18700 2798230 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18701
2/2
✓ Branch 0 taken 2788629 times.
✓ Branch 1 taken 5195 times.
2793824 if (rpos_handle.data() == cid)
18702 {
18703 5195 screen_combo_modify_preroutine(rpos_handle);
18704 5195 }
18705 2793824 });
18706 4406 }
18707 4406 void screen_combo_modify_post(int32_t cid)
18708 {
18709 4406 combo_caches::refresh(cid);
18710
18711 2798230 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18712
2/2
✓ Branch 0 taken 2788629 times.
✓ Branch 1 taken 5195 times.
2793824 if (rpos_handle.data() == cid)
18713 {
18714 5195 screen_combo_modify_postroutine(rpos_handle);
18715 5195 }
18716 2793824 });
18717
18718 143922 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
18719
2/2
✓ Branch 0 taken 139458 times.
✓ Branch 1 taken 58 times.
139516 if (ffc_handle.data() == cid)
18720 {
18721 58 screen_ffc_modify_postroutine(ffc_handle);
18722 58 }
18723 139516 });
18724 4406 }
18725
18726 94 void awaken_spinning_tile(const rpos_handle_t& rpos_handle)
18727 {
18728 94 int cid = rpos_handle.data();
18729 94 int cset = rpos_handle.cset();
18730 282 auto [x, y] = rpos_handle.xy();
18731
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
282 addenemy(rpos_handle.screen, x, y, (cset<<12)+eSPINTILE1, combobuf[cid].o_tile + zc_max(1,combobuf[cid].frames));
18732 94 }
18733
18734 // It stands for next_side_pos
18735 // moves sle_x and sle_y to the next position
18736 11464 void nsp(bool random)
18737 {
18738
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8203 times.
11464 if(random)
18739 {
18740
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
18741 {
18742 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
18743 1634 sle_y = (zc_oldrand()%10)*16;
18744 1634 }
18745 else
18746 {
18747 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
18748 1627 sle_x = (zc_oldrand()%15)*16;
18749 }
18750
18751 3261 return;
18752 }
18753
18754
2/2
✓ Branch 0 taken 6168 times.
✓ Branch 1 taken 2035 times.
8203 if(sle_x==0)
18755 {
18756
2/2
✓ Branch 0 taken 1855 times.
✓ Branch 1 taken 180 times.
2035 if(sle_y<160)
18757 1855 sle_y+=16;
18758 else
18759 180 sle_x+=16;
18760 2035 }
18761
2/2
✓ Branch 0 taken 2596 times.
✓ Branch 1 taken 3572 times.
6168 else if(sle_y==160)
18762 {
18763
2/2
✓ Branch 0 taken 2430 times.
✓ Branch 1 taken 166 times.
2596 if(sle_x<240)
18764 2430 sle_x+=16;
18765 else
18766 166 sle_y-=16;
18767 2596 }
18768
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 2020 times.
3572 else if(sle_x==240)
18769 {
18770
2/2
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 148 times.
1552 if(sle_y>0)
18771 1404 sle_y-=16;
18772 else
18773 148 sle_x-=16;
18774 1552 }
18775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
18776 {
18777
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
18778 2020 sle_x-=16;
18779 else
18780 sle_y+=16;
18781 2020 }
18782 11464 }
18783
18784 // moves sle_x and sle_y to the next available position
18785 // returns the direction the enemy should face
18786 2429 int32_t next_side_pos(int32_t screen, bool random)
18787 {
18788 bool blocked;
18789 2429 int32_t c=0;
18790 25357 auto [offx, offy] = translate_screen_coordinates_to_world(screen);
18791
18792 2429 do
18793 {
18794
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11333 times.
11464 nsp(c>35 ? false : random);
18795 22928 int x = sle_x + offx;
18796 22928 int y = sle_y + offy;
18797
4/4
✓ Branch 0 taken 2447 times.
✓ Branch 1 taken 9017 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2428 times.
13892 blocked = _walkflag(x,y,2) || _walkflag(x,y+8,2) ||
18798
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 (combo_class_buf[COMBOTYPE(x,y)].block_enemies ||
18799
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2428 times.
✗ Branch 3 not taken.
2428 MAPFLAG(x,y) == mfNOENEMY || MAPCOMBOFLAG(x,y)==mfNOENEMY ||
18800
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2428 times.
2428 MAPFLAG(x,y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(x,y)==mfNOGROUNDENEMY ||
18801 2428 iswaterex_z3(MAPCOMBO(x,y), -1, x, y, true));
18802
18803
2/2
✓ Branch 0 taken 11463 times.
✓ Branch 1 taken 1 times.
11464 if(++c>50)
18804 1 return -1;
18805
2/2
✓ Branch 0 taken 9035 times.
✓ Branch 1 taken 2428 times.
11463 }
18806 11463 while(blocked);
18807
18808 2428 int32_t dir=0;
18809
18810
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 736 times.
2428 if(sle_x==0) dir=right;
18811
18812
2/2
✓ Branch 0 taken 1859 times.
✓ Branch 1 taken 569 times.
2428 if(sle_y==0) dir=down;
18813
18814
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 708 times.
2428 if(sle_x==240) dir=left;
18815
18816
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 if(sle_y==168) dir=up;
18817
18818 2428 return dir;
18819 2429 }
18820
18821 bool can_side_load(int32_t id)
18822 {
18823 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18824 {
18825 return false;
18826 }
18827 switch(guysbuf[id].family) //id&0x0FFF)
18828 {
18829 //case eTEK1:
18830 //case eTEK2:
18831 //case eTEK3:
18832 //case eLEV1:
18833 //case eLEV2:
18834 //case eLEV3:
18835 //case eRAQUAM:
18836 //case eLAQUAM:
18837 //case eDODONGO:
18838 //case eMANHAN:
18839 //case eGLEEOK1:
18840 //case eGLEEOK2:
18841 //case eGLEEOK3:
18842 //case eGLEEOK4:
18843 //case eDIG1:
18844 //case eDIG3:
18845 //case eGOHMA1:
18846 //case eGOHMA2:
18847 //case eCENT1:
18848 //case eCENT2:
18849 //case ePATRA1:
18850 //case ePATRA2:
18851 //case eGANON:
18852 //case eMANHAN2:
18853 //case eCEILINGM: later
18854 //case eFLOORM: later
18855 //case ePATRABS:
18856 //case ePATRAL2:
18857 //case ePATRAL3:
18858 //case eGLEEOK1F:
18859 //case eGLEEOK2F:
18860 //case eGLEEOK3F:
18861 //case eGLEEOK4F:
18862 //case eDODONGOBS:
18863 //case eDODONGOF:
18864 //case eGOHMA3:
18865 //case eGOHMA4:
18866 //case eSHOOTMAGIC:
18867 //case eSHOOTROCK:
18868 //case eSHOOTSPEAR:
18869 //case eSHOOTSWORD:
18870 //case eSHOOTFLAME:
18871 //case eSHOOTFLAME2:
18872 //case eSHOOTFBALL:
18873 case eeTEK:
18874 case eeLEV:
18875 case eeAQUA:
18876 case eeDONGO:
18877 case eeMANHAN:
18878 case eeGLEEOK:
18879 case eeDIG:
18880 case eeGHOMA:
18881 case eeLANM:
18882 case eePATRA:
18883 case eeGANON:
18884 case eePROJECTILE:
18885 return false;
18886 break;
18887 }
18888
18889 return true;
18890 }
18891
18892 bool enemy_spawning_has_checked_been_here;
18893 static bool enemy_spawning_has_been_here;
18894
18895 35034 static bool check_if_recently_visited()
18896 {
18897
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 34512 times.
35034 if (enemy_spawning_has_checked_been_here)
18898 522 return enemy_spawning_has_been_here;
18899
18900 34512 int mi = mapind(cur_map, cur_screen);
18901
18902 34512 enemy_spawning_has_been_here = false;
18903
2/2
✓ Branch 0 taken 207072 times.
✓ Branch 1 taken 34512 times.
241584 for (int i = 0; i < 6; i++)
18904
2/2
✓ Branch 0 taken 197500 times.
✓ Branch 1 taken 9572 times.
216644 if (visited[i] == mi)
18905 9572 enemy_spawning_has_been_here = true;
18906
18907
2/2
✓ Branch 0 taken 9572 times.
✓ Branch 1 taken 24940 times.
34512 if (!enemy_spawning_has_been_here)
18908 {
18909 24940 visited[vhead] = mi; //If not, it adds it to the array,
18910 24940 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
18911 24940 }
18912
18913 34512 enemy_spawning_has_checked_been_here = true;
18914 34512 return enemy_spawning_has_been_here;
18915 35034 }
18916
18917 static std::array<bool, MAPSCRS> script_sle;
18918
18919 static int32_t sle_pattern = 0;
18920 static void script_side_load_enemies(mapscr* scr)
18921 {
18922 if (script_sle[scr->screen] || sle_clk) return;
18923
18924 sle_cnt = 0;
18925 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18926 ++sle_cnt;
18927 script_sle[scr->screen] = true;
18928 sle_pattern = scr->pattern;
18929 sle_clk = 0;
18930 }
18931
18932 54516 static void side_load_enemies(mapscr* scr)
18933 {
18934 54516 int screen = scr->screen;
18935
18936
3/4
✓ Branch 0 taken 683 times.
✓ Branch 1 taken 53833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 683 times.
54516 if (sle_clk==0 && !script_sle[scr->screen])
18937 {
18938 683 sle_pattern = scr->pattern;
18939 683 sle_cnt = 0;
18940 683 int32_t guycnt = 0;
18941
18942 683 int mi = mapind(cur_map, screen);
18943 683 bool reload=true;
18944 683 bool unbeatablereload = true;
18945
18946 683 load_default_enemies(scr);
18947
18948 683 bool beenhere = check_if_recently_visited();
18949
4/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 42 times.
683 if (beenhere && game->guys[mi] == 0)
18950 {
18951 42 sle_cnt=0;
18952 42 reload=false;
18953 42 }
18954
18955
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 641 times.
683 if(reload)
18956 {
18957 641 sle_cnt = game->guys[mi];
18958
18959
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 221 times.
641 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
18960 641 || sle_cnt==0)
18961 {
18962
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1272 times.
✓ Branch 2 taken 1054 times.
✓ Branch 3 taken 221 times.
1275 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18963 1054 ++sle_cnt;
18964 221 }
18965
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
641 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
18966 {
18967 for(int32_t i = 0; i<sle_cnt && scr->enemy[i]>0; i++)
18968 {
18969 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
18970 {
18971 unbeatablereload = false;
18972 }
18973 }
18974 if (unbeatablereload)
18975 {
18976 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18977 {
18978 ++sle_cnt;
18979 }
18980 }
18981 }
18982 641 }
18983
18984
3/4
✓ Branch 0 taken 652 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 652 times.
683 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN))
18985 {
18986 31 sle_cnt = 0;
18987
18988
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18989 108 ++sle_cnt;
18990 31 }
18991
18992
2/2
✓ Branch 0 taken 2446 times.
✓ Branch 1 taken 683 times.
3129 for(int32_t i=0; i<sle_cnt; i++)
18993 2446 ++guycnt;
18994
18995 683 game->guys[mi] = guycnt;
18996 683 }
18997
18998
2/2
✓ Branch 0 taken 52087 times.
✓ Branch 1 taken 2429 times.
54516 if((++sle_clk+8)%24 == 0)
18999 {
19000 2429 int32_t dir = next_side_pos(screen, sle_pattern==pSIDESR);
19001 6819 auto [x, y] = translate_screen_coordinates_to_world(screen, sle_x, sle_y);
19002
19003
6/6
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 2195 times.
✓ Branch 4 taken 233 times.
✓ Branch 5 taken 2195 times.
2429 if(dir==-1 || tooclose(x,y,32))
19004 {
19005 234 return;
19006 }
19007
19008 2195 int32_t enemy_slot=guys.Count();
19009
19010
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2195 times.
2195 while(sle_cnt > 0 && !ok2add(scr, scr->enemy[sle_cnt-1]))
19011 sle_cnt--;
19012
19013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
2195 if(sle_cnt > 0)
19014 {
19015
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2195 times.
6585 if(addenemy(screen, x,y,scr->enemy[--sle_cnt],0))
19016 {
19017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
2195 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
19018 {
19019 2195 guys.spr(enemy_slot)->dir = dir;
19020 2195 }
19021
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19022 {
19023 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19024 {
19025 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
19026 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
19027 }
19028 }
19029 2195 }
19030 2195 }
19031 2195 }
19032
19033
2/2
✓ Branch 0 taken 53704 times.
✓ Branch 1 taken 578 times.
54282 if(sle_cnt<=0)
19034 {
19035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if (script_sle[screen])
19036 script_sle[screen] = false;
19037 else
19038 {
19039 578 get_screen_state(screen).loaded_enemies = true;
19040 }
19041 578 sle_clk = 0;
19042 578 }
19043 54516 }
19044
19045 1253510 bool is_starting_pos(mapscr* scr, int32_t i, int32_t x, int32_t y, int32_t t)
19046 {
19047
2/2
✓ Branch 0 taken 116390 times.
✓ Branch 1 taken 1137120 times.
1253510 if (!is_in_scrolling_region())
19048
2/4
✓ Branch 0 taken 1137120 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1137120 times.
1137120 if(scr->enemy[i]<1||scr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
19049 {
19050 return false; //never 0, never OoB.
19051 }
19052 // No corner enemies
19053
6/6
✓ Branch 0 taken 1082501 times.
✓ Branch 1 taken 171009 times.
✓ Branch 2 taken 41283 times.
✓ Branch 3 taken 1123784 times.
✓ Branch 4 taken 117940 times.
✓ Branch 5 taken 94352 times.
1253510 if ((x==0 || x==world_w-16) && (y==0 || y==world_h-16))
19054 212292 return false;
19055
19056 //Is a no spawn combo...
19057
4/4
✓ Branch 0 taken 1123772 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1123776 times.
1123784 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19058 16 return false;
19059
19060 // No enemies in dungeon walls
19061
2/2
✓ Branch 0 taken 468703 times.
✓ Branch 1 taken 655073 times.
1123776 if (isdungeon(scr->screen))
19062 {
19063 655073 auto [offx, offy] = translate_screen_coordinates_to_world(scr->screen);
19064
17/18
✓ Branch 0 taken 655073 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 582513 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 582513 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 509953 times.
✓ Branch 7 taken 72560 times.
✓ Branch 8 taken 509953 times.
✓ Branch 9 taken 72560 times.
✓ Branch 10 taken 422881 times.
✓ Branch 11 taken 87072 times.
✓ Branch 12 taken 422881 times.
✓ Branch 13 taken 87072 times.
✓ Branch 14 taken 87072 times.
✓ Branch 15 taken 335809 times.
✓ Branch 16 taken 87072 times.
✓ Branch 17 taken 335809 times.
655073 if(isdungeon(scr->screen) && (x<32+offx || x>=224+offx || y<32+offy || y>=144+offy))
19065 319264 return false;
19066 335809 }
19067
19068 // Too close to hero
19069
4/4
✓ Branch 0 taken 77030 times.
✓ Branch 1 taken 727482 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 76929 times.
804512 if(tooclose(x,y,40) && t<11)
19070 76929 return false;
19071
19072 // Can't fly onto it?
19073
4/4
✓ Branch 0 taken 139611 times.
✓ Branch 1 taken 587972 times.
✓ Branch 2 taken 35960 times.
✓ Branch 3 taken 25255 times.
788798 if(isflier(scr->enemy[i])&&
19074
2/2
✓ Branch 0 taken 139221 times.
✓ Branch 1 taken 390 times.
139611 (flyerblocked(x+8,y+8,spw_floater,guysbuf[scr->enemy[i]])||
19075
2/2
✓ Branch 0 taken 61215 times.
✓ Branch 1 taken 78006 times.
139221 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19076 25645 return false;
19077
19078 // Can't jump onto it?
19079 if
19080 (
19081
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 88704 times.
790646 guysbuf[scr->enemy[i]].family==eeTEK
19082
19083
2/2
✓ Branch 0 taken 88722 times.
✓ Branch 1 taken 613216 times.
701938 &&
19084 (
19085
2/2
✓ Branch 0 taken 88715 times.
✓ Branch 1 taken 7 times.
88722 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19086
2/2
✓ Branch 0 taken 88714 times.
✓ Branch 1 taken 1 times.
88715 COMBOTYPE(x+8,y+8)==cNOENEMY||
19087
1/2
✓ Branch 0 taken 88714 times.
✗ Branch 1 not taken.
88714 ispitfall(x+8,y+8)||
19088
2/2
✓ Branch 0 taken 88708 times.
✓ Branch 1 taken 6 times.
88714 MAPFLAG(x+8,y+8)==mfNOENEMY||
19089 88708 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19090 )
19091 )
19092 {
19093 18 return false;
19094 }
19095
19096 // Other off-limit combos
19097
6/6
✓ Branch 0 taken 587950 times.
✓ Branch 1 taken 113970 times.
✓ Branch 2 taken 499246 times.
✓ Branch 3 taken 88704 times.
✓ Branch 4 taken 276486 times.
✓ Branch 5 taken 222760 times.
1201166 if((!isflier(scr->enemy[i])&& guysbuf[scr->enemy[i]].family!=eeTEK &&
19098
2/2
✓ Branch 0 taken 282044 times.
✓ Branch 1 taken 217202 times.
499246 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[scr->enemy[i]]))) &&
19099 499246 guysbuf[scr->enemy[i]].family!=eeZORA)
19100 222760 return false;
19101
19102 // Don't ever generate enemies on these combos!
19103
4/4
✓ Branch 0 taken 478856 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 478862 times.
479160 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19104 310 return false;
19105
19106 //BS Dodongos need at least 2 spaces.
19107
4/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 477823 times.
✓ Branch 2 taken 1014 times.
✓ Branch 3 taken 25 times.
478862 if ((guysbuf[scr->enemy[i]].family==eeDONGO)&&(guysbuf[scr->enemy[i]].attributes[9] == 1))
19108 {
19109
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19110
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19111
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19112 ((y>144)||_walkflag(x, y+24,2)))
19113 {
19114 return false;
19115 }
19116 19 }
19117
19118 478856 return true;
19119 1147368 }
19120
19121 160622 bool is_ceiling_pattern(int32_t i)
19122 {
19123
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 160602 times.
160622 return (i==pCEILING || i==pCEILINGR);
19124 }
19125
19126 5955 rpos_t placeenemy(mapscr* scr, int32_t i, int32_t offx, int32_t offy)
19127 {
19128 5955 std::vector<rpos_t> freeposcache;
19129
19130
2/2
✓ Branch 0 taken 65505 times.
✓ Branch 1 taken 5955 times.
71460 for(int32_t y=offy; y<offy+176; y+=16)
19131 {
19132
2/2
✓ Branch 0 taken 1048080 times.
✓ Branch 1 taken 65505 times.
1113585 for(int32_t x=offx; x<offx+256; x+=16)
19133 {
19134
3/4
✓ Branch 0 taken 1048080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421055 times.
✓ Branch 3 taken 627025 times.
1048080 if(is_starting_pos(scr,i,x,y,0))
19135 {
19136
2/4
✓ Branch 0 taken 421055 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421055 times.
✗ Branch 3 not taken.
421055 freeposcache.push_back(COMBOPOS_REGION(x, y));
19137 421055 }
19138 1048080 }
19139 65505 }
19140
19141
2/2
✓ Branch 0 taken 5944 times.
✓ Branch 1 taken 11 times.
5955 if (!freeposcache.empty())
19142
1/2
✓ Branch 0 taken 5944 times.
✗ Branch 1 not taken.
5944 return freeposcache[zc_oldrand()%freeposcache.size()];
19143
19144 11 return rpos_t::None;
19145 5955 }
19146
19147 81122 void spawnEnemy(mapscr* scr, int& pos, int& clk, int offx, int offy, int& fastguys, int& i, int& guycnt, int& loadcnt)
19148 {
19149 81122 int screen = scr->screen;
19150 81122 int x = 0;
19151 81122 int y = 0;
19152 81122 bool placed=false;
19153 81122 int32_t t=-1;
19154
19155 // First: enemy combo flags
19156
2/2
✓ Branch 0 taken 805334 times.
✓ Branch 1 taken 63756 times.
869090 for(int32_t sy=0; sy<176; sy+=16)
19157 {
19158
2/2
✓ Branch 0 taken 12756181 times.
✓ Branch 1 taken 787968 times.
13544149 for(int32_t sx=0; sx<256; sx+=16)
19159 {
19160 12756181 x = offx + sx;
19161 12756181 y = offy + sy;
19162 12756181 int32_t cflag = MAPFLAG(x, y);
19163 12756181 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19164
19165
2/4
✓ Branch 0 taken 12756181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12756181 times.
✗ Branch 3 not taken.
12756181 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19166 {
19167 if(!ok2add(scr, scr->enemy[i]))
19168 {
19169 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19170 }
19171 else
19172 {
19173 addenemy_z(screen,x,
19174 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19175 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19176
19177 ++guycnt;
19178
19179 placed=true;
19180 goto placed_enemy;
19181 }
19182 }
19183
19184
4/4
✓ Branch 0 taken 12738766 times.
✓ Branch 1 taken 17415 times.
✓ Branch 2 taken 12738766 times.
✓ Branch 3 taken 17415 times.
12756181 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19185 {
19186
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17366 times.
17415 if(!ok2add(scr, scr->enemy[i]))
19187 {
19188
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19189 49 }
19190 else
19191 {
19192 34732 addenemy_z(screen,x,
19193
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17365 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17366 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19194
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17365 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17366 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19195
19196 17366 ++guycnt;
19197
19198 17366 placed=true;
19199 17366 goto placed_enemy;
19200 }
19201 49 }
19202 12738815 }
19203 787968 }
19204
19205 // Next: enemy pattern
19206
6/8
✓ Branch 0 taken 4997 times.
✓ Branch 1 taken 58759 times.
✓ Branch 2 taken 58022 times.
✓ Branch 3 taken 5734 times.
✓ Branch 4 taken 58022 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 58022 times.
63756 if((scr->pattern==pRANDOM || scr->pattern==pCEILING) && !(isSideViewGravity()) && ((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS)))
19207 {
19208 58022 do
19209 {
19210
19211 // NES positions
19212 99509 pos%=9;
19213 99509 x=offx+stx[loadside][pos];
19214 99509 y=offy+sty[loadside][pos];
19215 99509 ++pos;
19216 99509 ++t;
19217
2/2
✓ Branch 0 taken 41487 times.
✓ Branch 1 taken 58022 times.
157531 }
19218
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 99288 times.
99509 while((t< 20) && !is_starting_pos(scr,i,x,y,t));
19219 58022 }
19220
19221
4/4
✓ Branch 0 taken 58022 times.
✓ Branch 1 taken 5734 times.
✓ Branch 2 taken 221 times.
✓ Branch 3 taken 57801 times.
63756 if(t<0 || t >= 20) // above enemy pattern failed
19222 {
19223 // Final chance: find a random position anywhere onscreen
19224 5955 rpos_t rand_rpos = placeenemy(scr, i, offx, offy);
19225
19226
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5944 times.
5955 if (rand_rpos != rpos_t::None)
19227 {
19228 5944 std::tie(x, y) = COMBOXY_REGION(rand_rpos);
19229 5944 }
19230 else // All opportunities failed - abort
19231 {
19232 11 return;
19233 }
19234 5944 }
19235
19236 {
19237 63745 int32_t c=0;
19238 63745 c=clk;
19239
19240
2/2
✓ Branch 0 taken 9643 times.
✓ Branch 1 taken 54102 times.
63745 if(!slowguy(scr->enemy[i]))
19241 54102 ++fastguys;
19242
2/2
✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 8057 times.
9643 else if(fastguys>0)
19243 1586 c=-15*(i-fastguys+2);
19244 else
19245 8057 c=-15*(i+1);
19246
19247
4/6
✓ Branch 0 taken 29160 times.
✓ Branch 1 taken 34585 times.
✓ Branch 2 taken 29160 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29160 times.
63745 if(BSZ&&((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19248 {
19249 // Special case for blue leevers
19250
4/4
✓ Branch 0 taken 1894 times.
✓ Branch 1 taken 27266 times.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 1133 times.
29160 if(guysbuf[scr->enemy[i]].family==eeLEV && guysbuf[scr->enemy[i]].attributes[0] == 1)
19251 761 c=-15*(i+1);
19252 else
19253 28399 c=-15;
19254 29160 }
19255
19256
2/2
✓ Branch 0 taken 62945 times.
✓ Branch 1 taken 800 times.
63745 if(!ok2add(scr, scr->enemy[i]))
19257 {
19258
4/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 670 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 130 times.
800 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19259 800 }
19260 else
19261 {
19262
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62945 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62945 if(((scr->enemy[i]>0||scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19263 {
19264
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62769 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
125890 addenemy_z(screen,x,(is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19265
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62769 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 176 times.
62945 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],c);
19266
19267 62945 ++guycnt;
19268 62945 }
19269 }
19270
19271 63745 placed=true;
19272 63745 } // if(t < 20)
19273
19274 placed_enemy:
19275
19276 // I don't like this, but it seems to work...
19277 static bool foundCarrier;
19278
19279
2/2
✓ Branch 0 taken 59501 times.
✓ Branch 1 taken 21610 times.
81111 if(i==0)
19280 21610 foundCarrier=false;
19281
19282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81111 times.
81111 if(placed)
19283 {
19284
4/4
✓ Branch 0 taken 21610 times.
✓ Branch 1 taken 59501 times.
✓ Branch 2 taken 21441 times.
✓ Branch 3 taken 169 times.
81111 if(i==0 && scr->flags11&efLEADER)
19285 {
19286 169 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19287
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 7 times.
169 if (e)
19288 {
19289 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19290
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if ((e->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER))
19291 {
19292 e = find_guy_nth_for_id(screen, scr->enemy[i], 2, 0xFFF);
19293 }
19294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if (e)
19295 {
19296 162 e->leader = true;
19297 162 }
19298 162 }
19299 169 }
19300
19301 81111 ScreenItemState item_state = get_screen_state(screen).item_state;
19302
5/6
✓ Branch 0 taken 80876 times.
✓ Branch 1 taken 235 times.
✓ Branch 2 taken 80876 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✓ Branch 5 taken 80800 times.
81111 if (!foundCarrier && (item_state == ScreenItemState::CarriedByEnemy || item_state == ScreenItemState::MustGiveToEnemy))
19303 {
19304 76 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19305
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
76 if (e && (e->flags&guy_doesnt_count)==0)
19306 {
19307 76 e->itemguy = true;
19308 76 foundCarrier=true;
19309 76 }
19310 76 }
19311 81111 }
19312 81122 }
19313
19314 // returns index of first sprite with matching id, -1 if none found
19315 245 enemy* find_guy_first_for_id(int screen, int id, int mask)
19316 {
19317 245 int count = guys.Count();
19318
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 7 times.
372 for (int32_t i=0; i<count; i++)
19319 {
19320 365 enemy* e = (enemy*)guys.spr(i);
19321
4/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 238 times.
✓ Branch 3 taken 79 times.
365 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19322 {
19323 238 return e;
19324 }
19325 127 }
19326
19327 7 return nullptr;
19328 245 }
19329
19330 enemy* find_guy_nth_for_id(int screen, int id, int n, int mask)
19331 {
19332 int count = guys.Count();
19333 for(int32_t i=0; i<count; i++)
19334 {
19335 enemy* e = (enemy*)guys.spr(i);
19336 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19337 {
19338 if (n > 1) --n;
19339 else return e;
19340 }
19341 }
19342 return nullptr;
19343 }
19344
19345 bool scriptloadenemies(int screen)
19346 {
19347 if (sle_clk || script_sle[screen]) return false;
19348
19349 mapscr* scr = get_scr(screen);
19350 if(scr->pattern==pNOSPAWN) return false;
19351
19352 if(scr->pattern==pSIDES || scr->pattern==pSIDESR)
19353 {
19354 script_side_load_enemies(scr);
19355 return true;
19356 }
19357
19358 auto [x, y] = translate_screen_coordinates_to_world(screen);
19359 int32_t pos=zc_oldrand()%9;
19360 int32_t clk=-15,fastguys=0;
19361 int32_t i=0,guycnt=0;
19362 int32_t loadcnt = 10;
19363
19364 for(; i<loadcnt && scr->enemy[i]>0; i++)
19365 {
19366 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19367 spawnEnemy(scr, pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19368 if (guys.Count() > preguycount)
19369 {
19370 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19371 {
19372 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19373 {
19374 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19375 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19376 }
19377 }
19378 }
19379 --clk;
19380 }
19381 return true;
19382 }
19383
19384 14246451 void loadenemies()
19385 {
19386 28873060 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
19387 14626609 int screen = scr->screen;
19388 14626609 auto& state = get_screen_state(screen);
19389
2/2
✓ Branch 0 taken 14211396 times.
✓ Branch 1 taken 415213 times.
14626609 if (state.loaded_enemies)
19390 14211396 return;
19391
19392 // dungeon basements
19393 static byte dngn_enemy_x[4] = {32,96,144,208};
19394
2/2
✓ Branch 0 taken 148964 times.
✓ Branch 1 taken 266249 times.
415213 if (cur_screen>=128)
19395 {
19396
2/2
✓ Branch 0 taken 148489 times.
✓ Branch 1 taken 475 times.
148964 if(DMaps[cur_dmap].flags&dmfCAVES) return;
19397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[cur_dmap].flags&dmfNEWCELLARENEMIES )
19398 {
19399 for(int32_t i=0; i<10; i++)
19400 {
19401 if ( scr->enemy[i] )
19402 {
19403 int32_t preguycount = guys.Count();
19404 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i],-14-i);
19405 if (guys.Count() > preguycount)
19406 {
19407 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19408 {
19409 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19410 {
19411 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19412 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19413 }
19414 }
19415 }
19416 }
19417 }
19418 }
19419 else
19420 {
19421
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
19422 {
19423 1900 int32_t preguycount = guys.Count();
19424
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i]?scr->enemy[i]:(int32_t)eKEESE1,-14-i);
19425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
19426 {
19427
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19428 {
19429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19430 {
19431 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19432 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19433 4 }
19434 4 }
19435 1900 }
19436 1900 }
19437 }
19438
19439 475 state.loaded_enemies = true;
19440 475 return;
19441 }
19442
19443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 266249 times.
266249 if (scr->pattern == pNOSPAWN)
19444 return;
19445
19446 // TODO: configure when screen enemies spawn.
19447
2/2
✓ Branch 0 taken 88957 times.
✓ Branch 1 taken 177292 times.
266249 if (!viewport.intersects_with(region_scr_x*256, region_scr_y*176, 256, 176))
19448 177292 return;
19449
19450
4/4
✓ Branch 0 taken 50510 times.
✓ Branch 1 taken 38447 times.
✓ Branch 2 taken 16069 times.
✓ Branch 3 taken 34441 times.
88957 if (scr->pattern==pSIDES || scr->pattern==pSIDESR)
19451 {
19452 54516 side_load_enemies(scr);
19453 54516 return;
19454 }
19455
19456 34441 state.loaded_enemies = true;
19457
19458 // check if it's the dungeon boss and it has been beaten before
19459
4/4
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 34082 times.
✓ Branch 2 taken 269 times.
✓ Branch 3 taken 90 times.
34441 if (scr->flags11&efBOSS && game->lvlitems[dlevel]&liBOSS)
19460 90 return;
19461
19462 34351 int32_t loadcnt = 10;
19463 34351 int16_t mi = mapind(cur_map, screen);
19464 34351 bool beenhere = check_if_recently_visited();
19465
19466 //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19467 34351 bool reload = true;
19468
4/4
✓ Branch 0 taken 9715 times.
✓ Branch 1 taken 24636 times.
✓ Branch 2 taken 4708 times.
✓ Branch 3 taken 5007 times.
34351 if (beenhere && game->guys[mi] == 0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19469 {
19470 5007 loadcnt = 0; //It will tell it not to load any enemies,
19471 5007 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19472 5007 }
19473
19474 34351 bool unbeatablereload = true;
19475
2/2
✓ Branch 0 taken 5007 times.
✓ Branch 1 taken 29344 times.
34351 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19476 {
19477 29344 loadcnt = game->guys[mi]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19478
19479
2/4
✓ Branch 0 taken 10289 times.
✓ Branch 1 taken 19055 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29344 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10289 times.
10289 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19481 19055 loadcnt = 10; //That means all enemies need to be respawned.
19482
3/4
✓ Branch 0 taken 24636 times.
✓ Branch 1 taken 4708 times.
✓ Branch 2 taken 24636 times.
✗ Branch 3 not taken.
29344 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19483 {
19484 for(int32_t i = 0; i<loadcnt && scr->enemy[i]>0; i++)
19485 {
19486 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
19487 {
19488 unbeatablereload = false;
19489 }
19490 }
19491 if (unbeatablereload)
19492 {
19493 loadcnt = 10;
19494 }
19495 }
19496 29344 }
19497
19498
4/4
✓ Branch 0 taken 32892 times.
✓ Branch 1 taken 1459 times.
✓ Branch 2 taken 193 times.
✓ Branch 3 taken 32699 times.
34351 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19499 1652 loadcnt = 10; //All enemies also need to be respawned.
19500
19501 // do enemies that are always loaded
19502 34351 load_default_enemies(scr);
19503 34351 activate_fireball_statues(scr);
19504
19505 34351 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19506 34351 int32_t clk=-15,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
19507 34351 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19508
4/4
✓ Branch 0 taken 15149 times.
✓ Branch 1 taken 100324 times.
✓ Branch 2 taken 81122 times.
✓ Branch 3 taken 34351 times.
115473 for(; i<loadcnt && scr->enemy[i]>0; i++)
19509 {
19510 81122 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19511 81122 spawnEnemy(scr, pos, clk, region_scr_x*256, region_scr_y*176, fastguys, i, guycnt, loadcnt);
19512
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 80311 times.
81122 if (guys.Count() > preguycount)
19513 {
19514
2/2
✓ Branch 0 taken 77960 times.
✓ Branch 1 taken 2351 times.
80311 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19515 {
19516
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2347 times.
2351 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19517 {
19518 2347 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19519 2347 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19520 2347 }
19521 2351 }
19522 80311 }
19523
19524 81122 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19525 81122 }
19526
19527 34351 game->guys[mi] = guycnt;
19528 14626609 });
19529 14246451 }
19530
19531 233 void moneysign()
19532 {
19533 466 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
19534 466 additem(dx+48,dy+108,iRupy,ipDUMMY);
19535 233 set_clip_state(pricesdisplaybuf, 0);
19536 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19537 233 }
19538
19539 3302 void putprices(bool sign)
19540 {
19541
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 3270 times.
3302 if(fadeclk > 0) return;
19542
19543 3270 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19544 3270 int32_t step=32;
19545 3270 int32_t x=80;
19546
19547
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2989 times.
3270 if(prices[2]==0)
19548 {
19549 2989 step<<=1;
19550
19551
2/2
✓ Branch 0 taken 2957 times.
✓ Branch 1 taken 32 times.
2989 if(prices[1]==0)
19552 {
19553 2957 x=112;
19554 2957 }
19555 2989 }
19556
19557
2/2
✓ Branch 0 taken 3270 times.
✓ Branch 1 taken 9810 times.
13080 for(int32_t i=0; i<3; i++)
19558 {
19559 // Kind of stupid, but it works: 100000 is used to indicate that an item
19560 // has a price of zero rather than there being no item.
19561 // 100000 isn't a valid price, so this doesn't cause problems.
19562
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 8771 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
9810 if(prices[i]!=0 && prices[i]<100000)
19563 {
19564 char buf[8];
19565 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19566
19567 1039 int32_t l=(int32_t)strlen(buf);
19568 1039 set_clip_state(pricesdisplaybuf, 0);
19569
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19570 1039 }
19571
19572 9810 x+=step;
19573 9810 }
19574 3302 }
19575
19576 // Setting up special rooms
19577 // Also called when the Letter is used successfully.
19578 1210 void setupscreen()
19579 {
19580 1210 boughtsomething=false;
19581
19582 // Either the origin screen, or if in a 0x80 room the screen player came from.
19583
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 794 times.
1210 mapscr* base_scr = cur_screen >= 128 ? special_warp_return_scr : origin_scr;
19584 1210 mapscr* scr = origin_scr;
19585
19586 1210 word str=base_scr->str;
19587
19588 2262 auto [dx, dy] = translate_screen_coordinates_to_world(scr->screen);
19589
19590 // Prices are already set to 0 in dowarp()
19591
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 689 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1210 switch(base_scr->room)
19592 {
19593 case rSP_ITEM: // special item
19594 328 additem(dx+120,dy+89,base_scr->catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19595 164 break;
19596
19597 case rINFO: // pay for info
19598 {
19599 28 int32_t count = 0;
19600 28 int32_t base = 88;
19601 28 int32_t step = 5;
19602
19603 28 moneysign();
19604
19605
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19606 {
19607
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[base_scr->catchall].str[i])
19608 {
19609 84 ++count;
19610 84 }
19611 else
19612 break;
19613 84 }
19614
19615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19616 {
19617
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19618 {
19619 base = 88+32;
19620 }
19621
19622
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19623 {
19624 step = 6;
19625 }
19626
19627
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19628 {
19629 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19630 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19631 84 prices[i] = -(QMisc.info[base_scr->catchall].price[i]);
19632
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19633 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19634 84 int32_t itemid = current_item_id(itype_wealthmedal);
19635
19636
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19637 {
19638 if(itemsbuf[itemid].flags & item_flag1)
19639 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19640 else
19641 prices[i]-=itemsbuf[itemid].misc1;
19642 prices[i]=vbound(prices[i], -99999, 0);
19643 if(prices[i]==0)
19644 prices[i]=100000;
19645 }
19646
19647
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[base_scr->catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19648 prices[i]=-1;
19649 84 }
19650 28 }
19651
19652 28 break;
19653 }
19654
19655 case rMONEY: // secret money
19656 88 additem(dx+120,dy+89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19657 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19658 44 break;
19659
19660 case rGAMBLE: // gambling
19661 11 prices[0]=prices[1]=prices[2]=-10;
19662 11 moneysign();
19663 22 additem(dx+88,dy+89,iRupy,ipMONEY+ipDUMMY);
19664 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19665 22 additem(dx+120,dy+89,iRupy,ipMONEY+ipDUMMY);
19666 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19667 22 additem(dx+152,dy+89,iRupy,ipMONEY+ipDUMMY);
19668 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19669 11 break;
19670
19671 case rREPAIR: // door repair
19672
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19673 // }
19674 13 repaircharge=base_scr->catchall;
19675 13 break;
19676
19677 case rMUPGRADE: // upgrade magic
19678 2 adjustmagic=true;
19679 2 break;
19680
19681 case rLEARNSLASH: // learn slash attack
19682 2 learnslash=true;
19683 2 break;
19684
19685 case rRP_HC: // heart container or red potion
19686 34 additem(dx+88,dy+89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19687 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19688 34 additem(dx+152,dy+89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19689 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19690 17 break;
19691
19692 case rP_SHOP: // potion shop
19693
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
19694 {
19695 12 str=0;
19696 12 break;
19697 }
19698
19699 [[fallthrough]];
19700 case rTAKEONE: // take one
19701 case rSHOP: // shop
19702 {
19703 194 int32_t count = 0;
19704 194 int32_t base = 88;
19705 194 int32_t step = 5;
19706
19707
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(base_scr->room != rTAKEONE)
19708 193 moneysign();
19709
19710 //count and align the stuff
19711
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
19712 {
19713
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[base_scr->catchall].hasitem[count] != 0)
19714 {
19715 523 ++count;
19716 523 }
19717 else
19718 {
19719 37 break;
19720 }
19721 523 }
19722
19723
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
19724 {
19725 22 base = 88+32;
19726 22 }
19727
19728
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
19729 {
19730 15 step = 6;
19731 15 }
19732
19733
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
19734 {
19735 1046 additem(dx+(i<<step)+base, dy+89, QMisc.shop[base_scr->catchall].item[i], ipHOLDUP+ipFADE+(base_scr->room == rTAKEONE ? ipONETIME2 : ipCHECK));
19736 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19737
19738
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(base_scr->room != rTAKEONE)
19739 {
19740 521 prices[i] = QMisc.shop[base_scr->catchall].price[i];
19741
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
19742 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19743 521 int32_t itemid = current_item_id(itype_wealthmedal);
19744
19745
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
19746 {
19747
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
19748 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
19749 else
19750 prices[i]+=itemsbuf[itemid].misc1;
19751 9 prices[i]=vbound(prices[i], 0, 99999);
19752
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
19753 prices[i]=100000;
19754 9 }
19755
19756
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[base_scr->catchall].price[i])>1 && prices[i]<1)
19757 prices[i]=1;
19758 521 }
19759 523 }
19760
19761 194 break;
19762 }
19763 case rBOTTLESHOP: // bottle shop
19764 {
19765 1 int32_t count = 0;
19766 1 int32_t base = 88;
19767 1 int32_t step = 5;
19768
19769 1 moneysign();
19770 1 bottleshoptype const& bst = QMisc.bottle_shop_types[base_scr->catchall];
19771 //count and align the stuff
19772
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
19773 {
19774
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
19775 {
19776 3 ++count;
19777 3 }
19778 else
19779 {
19780 break;
19781 }
19782 3 }
19783
19784
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
19785 {
19786 base = 88+32;
19787 }
19788
19789
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
19790 {
19791 step = 6;
19792 }
19793
19794
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
19795 {
19796 6 adddummyitem(dx+(i<<step)+base, dy+89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
19797 //{ Setup dummy item
19798 3 item* curItem = ((item*)items.spr(items.Count()-1));
19799 3 curItem->PriceIndex = i;
19800 3 newcombo const& cmb = combobuf[bst.comb[i]];
19801 3 curItem->o_tile = cmb.o_tile;
19802 3 curItem->o_cset = bst.cset[i];
19803 3 curItem->cs = curItem->o_cset;
19804 3 curItem->tile = cmb.o_tile;
19805 3 curItem->o_speed = cmb.speed;
19806 3 curItem->o_delay = 0;
19807 3 curItem->frames = cmb.frames;
19808 3 curItem->flip = cmb.flip;
19809 3 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
19810 3 curItem->pstring = 0;
19811 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
19812 3 curItem->flash = false;
19813 3 curItem->twohand = false;
19814 3 curItem->anim = true;
19815 3 curItem->hit_width=1;
19816 3 curItem->hyofs=4;
19817 3 curItem->hit_height=12;
19818 3 curItem->script=0;
19819 3 curItem->txsz=1;
19820 3 curItem->tysz=1;
19821 //}
19822
19823 3 prices[i] = bst.price[i];
19824
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
19825 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19826 3 int32_t itemid = current_item_id(itype_wealthmedal);
19827
19828
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
19829 {
19830 if(itemsbuf[itemid].flags & item_flag1)
19831 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19832 else
19833 prices[i]+=itemsbuf[itemid].misc1;
19834 prices[i]=vbound(prices[i], 0, 99999);
19835 if(prices[i]==0)
19836 prices[i]=100000;
19837 }
19838
19839
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
19840 prices[i]=1;
19841 3 }
19842
19843 1 break;
19844 }
19845
19846 case rBOMBS: // more bombs
19847 38 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19848 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19849 19 prices[0]=-base_scr->catchall;
19850 19 break;
19851
19852 case rARROWS: // more arrows
19853 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19854 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19855 prices[0]=-base_scr->catchall;
19856 break;
19857
19858 case rSWINDLE: // leave heart container or money
19859 28 additem(dx+88,dy+89,iHeartC,ipDUMMY+ipMONEY);
19860 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19861 14 prices[0]=-1;
19862 28 additem(dx+152,dy+89,iRupy,ipDUMMY+ipMONEY);
19863 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19864 14 prices[1]=-base_scr->catchall;
19865 14 break;
19866
19867 }
19868
19869
3/4
✓ Branch 0 taken 1191 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1191 times.
1210 if(base_scr->room == rBOMBS || base_scr->room == rARROWS)
19870 {
19871 19 int32_t i = (base_scr->room == rSWINDLE ? 1 : 0);
19872 19 int32_t itemid = current_item_id(itype_wealthmedal);
19873
19874
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
19875 {
19876 if(itemsbuf[itemid].flags & item_flag1)
19877 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
19878 else
19879 prices[i]+=itemsbuf[itemid].misc1;
19880 }
19881
19882
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(base_scr->catchall>1 && prices[i]>-1)
19883 prices[i]=-1;
19884 19 }
19885
19886 1210 putprices(false);
19887
19888
2/2
✓ Branch 0 taken 1151 times.
✓ Branch 1 taken 59 times.
1210 if(str)
19889 {
19890 1151 donewmsg(base_scr, str);
19891 1151 }
19892 else
19893 {
19894 59 Hero.unfreeze();
19895 }
19896 1210 }
19897
19898 enum
19899 {
19900 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
19901 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
19902
19903 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
19904
19905 MNU_DATA_MAX
19906 };
19907 struct menu_choice
19908 {
19909 int32_t x, y;
19910 int32_t pos;
19911 int32_t upos, dpos, lpos, rpos;
19912 18 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
19913 18 {}
19914 18 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
19915 int32_t dpos, int32_t lpos, int32_t rpos)
19916 18 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
19917 18 {}
19918 };
19919 static int32_t msg_menu_data[MNU_DATA_MAX];
19920 static bool do_run_menu = false;
19921 bool do_end_str = false;
19922 static bool wait_advance = false;
19923 399 static std::map<int32_t, menu_choice> menu_options;
19924 43835 void clr_msg_data()
19925 {
19926 43835 do_end_str = false;
19927 43835 wait_advance = false;
19928 43835 do_run_menu = false;
19929 43835 menu_options.clear();
19930 43835 memset(msg_menu_data, 0, sizeof(msg_menu_data));
19931 43835 }
19932
19933 static char namebuf[9] = {0};
19934 static char* nameptr = NULL;
19935 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
19936 2036 bool runMenuCursor()
19937 {
19938 2036 clear_bitmap(msg_menu_bmp_buf);
19939
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(!menu_options.size())
19940 {
19941 msg_menu_data[MNU_CHOSEN] = 0;
19942 return true; //end menu
19943 }
19944 2036 int32_t pos = msg_menu_data[MNU_CHOSEN];
19945 //If the cursor is at an invalid pos, find the first pos >= 0...
19946
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19947 {
19948 pos = 0;
19949 while(menu_options.find(pos) == menu_options.end())
19950 ++pos;
19951 }
19952 2036 menu_choice* ch = &menu_options[pos];
19953
19954 2036 bool pressed = true;
19955
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2032 times.
2036 if(rUp()) pos = ch->upos;
19956
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2030 times.
2032 else if(rDown()) pos = ch->dpos;
19957
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2021 times.
2030 else if(rLeft()) pos = ch->lpos;
19958
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2010 times.
2021 else if(rRight()) pos = ch->rpos;
19959 2010 else pressed = false;
19960
19961
2/2
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
2036 if(pressed)
19962 26 msg_menu_data[MNU_TIMER] = 1;
19963
19964 2036 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
19965 2036 bool held = false;
19966
2/2
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 90 times.
2036 if(hold_input)
19967 {
19968 90 held = true;
19969
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 89 times.
90 if(Up()) pos = ch->upos;
19970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Down()) pos = ch->dpos;
19971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Left()) pos = ch->lpos;
19972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Right()) pos = ch->rpos;
19973 89 else held = false;
19974 90 }
19975 //If the cursor is at an invalid pos, find the first pos >= 0...
19976
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19977 {
19978 pos = 0;
19979 while(menu_options.find(pos) == menu_options.end())
19980 ++pos;
19981 }
19982
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2009 times.
✓ Branch 3 taken 27 times.
2036 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
19983 27 sfx(MsgStrings[msgstr].sfx);
19984
19985 2036 ch = &menu_options[pos];
19986 4072 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
19987 2036 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
19988 2036 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
19989 2036 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
19990
19991 2036 msg_menu_data[MNU_CHOSEN] = pos;
19992
19993
2/2
✓ Branch 0 taken 1433 times.
✓ Branch 1 taken 603 times.
2036 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
19994 {
19995 603 rAbtn(); //Eat
19996
2/2
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 5 times.
603 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
19997 603 }
19998
19999
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2009 times.
2036 bool ret = (pressed || held) ? false : rAbtn();
20000 //Eat inputs
20001 2036 rUp(); rDown(); rLeft(); rRight(); rAbtn();
20002
20003
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 5 times.
2036 if(ret)
20004 5 menu_options.clear();
20005
20006 2036 return ret;
20007 //false if pos changed this frame; no confirming while moving the cursor!
20008 2036 }
20009
20010 839236 bool bottom_margin_clip()
20011 {
20012 890472 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
20013
2/2
✓ Branch 0 taken 788000 times.
✓ Branch 1 taken 51236 times.
839236 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
20014 }
20015
20016 void update_msgstr();
20017
20018 3293 static bool parsemsgcode(const StringCommand& command)
20019 {
20020 3293 auto& args = command.args;
20021 3293 int last_arg = 0;
20022
20023
18/38
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1280 times.
✓ Branch 3 taken 1644 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 56 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 70 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 11 times.
✓ Branch 14 taken 22 times.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 122 times.
✓ Branch 24 taken 28 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 5 times.
✓ Branch 29 taken 18 times.
✓ Branch 30 taken 5 times.
✓ Branch 31 taken 7 times.
✓ Branch 32 taken 3 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
3293 switch (command.code)
20024 {
20025 case MSGC_NEWLINE:
20026 {
20027 1280 ssc_tile_hei = ssc_tile_hei_buf;
20028
2/2
✓ Branch 0 taken 1278 times.
✓ Branch 1 taken 2 times.
1280 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20029 1280 ssc_tile_hei_buf = -1;
20030 1280 cursor_y += thei + MsgStrings[msgstr].vspace;
20031 1280 cursor_x=msg_margins[left];
20032 1280 return true;
20033 }
20034
20035 case MSGC_COLOUR:
20036 {
20037 1644 int32_t cset = args[0];
20038 1644 msgcolour = CSET(cset)+(args[1]);
20039 1644 return true;
20040 }
20041
20042 case MSGC_SHDCOLOR:
20043 {
20044 int32_t cset = args[0];
20045 msg_shdcol = CSET(cset)+args[1];
20046 return true;
20047 }
20048 case MSGC_SHDTYPE:
20049 {
20050 msg_shdtype = args[0];
20051 return true;
20052 }
20053
20054 case MSGC_SPEED:
20055 {
20056 56 msgspeed=args[0];
20057 56 return true;
20058 }
20059
20060 case MSGC_CTRUP:
20061 {
20062 int32_t a1 = args[0];
20063 int32_t a2 = args[1];
20064 game->change_counter(a2, a1);
20065 return true;
20066 }
20067
20068 case MSGC_CTRDN:
20069 {
20070 5 int32_t a1 = args[0];
20071 5 int32_t a2 = args[1];
20072 5 game->change_counter(-a2, a1);
20073 5 return true;
20074 }
20075
20076 case MSGC_CTRSET:
20077 {
20078 7 int32_t a1 = args[0];
20079 7 int32_t a2 = args[1];
20080 7 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20081 7 return true;
20082 }
20083
20084 case MSGC_CTRUPPC:
20085 case MSGC_CTRDNPC:
20086 case MSGC_CTRSETPC:
20087 {
20088 2 int32_t counter = args[0];
20089 2 int32_t amount = args[1];
20090 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20091
20092
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(command.code==MSGC_CTRDNPC)
20093 amount*=-1;
20094
20095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(command.code==MSGC_CTRSETPC)
20096 game->set_counter(amount, counter);
20097 else
20098 2 game->change_counter(amount, counter);
20099
20100 2 return true;
20101 }
20102
20103 case MSGC_GIVEITEM:
20104 {
20105 70 int32_t itemID = args[0];
20106
20107 70 getitem(itemID, true);
20108
2/4
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
70 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20109 {
20110 70 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20111 70 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
20112 70 }
20113 70 return true;
20114 }
20115
20116
20117 case MSGC_WARP:
20118 {
20119 int32_t dmap = args[0];
20120 int32_t scrn = args[1];
20121 int32_t dx = args[2];
20122 int32_t dy = args[3];
20123 int32_t wfx = args[4];
20124 int32_t sfx = args[5];
20125 if(dx >= MAX_SCC_ARG) dx = -1;
20126 if(dy >= MAX_SCC_ARG) dy = -1;
20127 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20128 do_end_str = true;
20129 return true;
20130 }
20131
20132 case MSGC_SETSCREEND:
20133 {
20134 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20135 int32_t screen = args[1];
20136 int32_t reg = args[2];
20137 int32_t val = args[3];
20138 FFCore.set_screen_d(screen + dmap, reg, val);
20139 return true;
20140 }
20141 case MSGC_TAKEITEM:
20142 {
20143 11 int32_t itemID = args[0];
20144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( FFCore.doscript(ScriptType::Item, itemID) )
20145 {
20146 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20147 }
20148 11 takeitem(itemID);
20149
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_bwpn == itemID )
20150 {
20151 game->forced_bwpn = -1;
20152 } //not else if! -Z
20153
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_awpn == itemID )
20154 {
20155 game->forced_awpn = -1;
20156 }
20157
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_xwpn == itemID )
20158 {
20159 game->forced_xwpn = -1;
20160 } //not else if! -Z
20161
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_ywpn == itemID )
20162 {
20163 game->forced_ywpn = -1;
20164 }
20165 11 verifyBothWeapons();
20166 11 return true;
20167 }
20168
20169 case MSGC_SFX:
20170 {
20171 22 sfx(args[0],128);
20172 22 return true;
20173 }
20174
20175 case MSGC_MIDI:
20176 {
20177 7 int32_t music = args[0];
20178
20179
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20180 1 music_stop();
20181 else
20182 6 jukebox(music+(ZC_MIDI_COUNT-1));
20183
20184 7 return true;
20185 }
20186
20187 case MSGC_FONT:
20188 {
20189 int fontid = args[0];
20190 int oh = text_height(msgfont);
20191 msgfont = get_zc_font(fontid);
20192 int nh = text_height(msgfont);
20193 int mh = std::max(oh,nh);
20194 if(mh > ssc_tile_hei_buf)
20195 ssc_tile_hei_buf = mh;
20196 return true;
20197 }
20198 case MSGC_RUN_FRZ_GENSCR:
20199 {
20200 word scr_id = args[0];
20201 bool force_redraw = args[1]!=0;
20202 if(force_redraw)
20203 {
20204 update_msgstr();
20205 draw_screen();
20206 }
20207 FFCore.runGenericFrozenEngine(scr_id);
20208 return true;
20209 }
20210 case MSGC_DRAWTILE:
20211 {
20212 int32_t tl = args[0];
20213 int32_t cs = args[1];
20214 int32_t t_wid = args[2];
20215 int32_t t_hei = args[3];
20216 int32_t fl = args[4];
20217
20218 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20219 {
20220 ssc_tile_hei = ssc_tile_hei_buf;
20221 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20222 ssc_tile_hei_buf = -1;
20223 cursor_y += thei + MsgStrings[msgstr].vspace;
20224 if(bottom_margin_clip()) return true;
20225 cursor_x=msg_margins[left];
20226 }
20227
20228 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20229 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20230 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20231 return true;
20232 }
20233
20234 case MSGC_GOTOIFRAND:
20235 {
20236 1 int32_t odds = args[0];
20237
20238 1 last_arg = 1;
20239
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!odds || !(zc_oldrand()%odds))
20240 1 goto switched;
20241
20242 return true;
20243 }
20244
20245 case MSGC_GOTOIFGLOBAL:
20246 {
20247 int32_t arg = args[0];
20248 int32_t d = zc_min(7,arg);
20249 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20250 arg = args[1];
20251
20252 if(game->screen_d[s][d] >= arg)
20253 {
20254 last_arg = 2;
20255 goto switched;
20256 }
20257
20258 return true;
20259 }
20260
20261 case MSGC_CHANGEPORTRAIT:
20262 {
20263 return true; //not implemented
20264 }
20265
20266 case MSGC_GOTOIFCREEND:
20267 {
20268 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20269 int32_t screen = args[1];
20270 int32_t reg = args[2];
20271 int32_t val = args[3];
20272 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20273 {
20274 last_arg = 4;
20275 goto switched;
20276 }
20277 return true;
20278 }
20279
20280 case MSGC_GOTOIF:
20281 {
20282 122 int32_t it = args[0];
20283
20284
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20285 {
20286 35 last_arg = 1;
20287 35 goto switched;
20288 }
20289
20290 87 return true;
20291 }
20292
20293 case MSGC_GOTOIFCTR:
20294 {
20295
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(game->get_counter(args[0]) >= args[1])
20296 {
20297 14 last_arg = 2;
20298 14 goto switched;
20299 }
20300
20301 14 return true;
20302 }
20303
20304 case MSGC_GOTOIFCTRPC:
20305 {
20306 int32_t counter = args[0];
20307 int32_t amount = (int32_t)((args[1]/100)*game->get_maxcounter(counter));
20308
20309 if(game->get_counter(counter)>=amount)
20310 {
20311 last_arg = 2;
20312 goto switched;
20313 }
20314
20315 return true;
20316 }
20317
20318 case MSGC_GOTOIFTRICOUNT:
20319 {
20320 if(TriforceCount() >= args[0])
20321 {
20322 last_arg = 1;
20323 goto switched;
20324 }
20325
20326 return true;
20327 }
20328
20329 case MSGC_GOTOIFTRI:
20330 {
20331 int32_t lev = args[0];
20332
20333 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20334 {
20335 last_arg = 1;
20336 goto switched;
20337 }
20338
20339 return true;
20340 }
20341
20342 case MSGC_SETUPMENU:
20343 {
20344 5 msg_menu_data[MNU_CURSOR_TILE] = args[0];
20345 5 msg_menu_data[MNU_CURSOR_CSET] = args[1];
20346 5 msg_menu_data[MNU_CURSOR_WID] = args[2];
20347 5 msg_menu_data[MNU_CURSOR_HEI] = args[3];
20348 5 msg_menu_data[MNU_CURSOR_FLIP] = args[4];
20349 5 return true;
20350 }
20351
20352 case MSGC_MENUCHOICE:
20353 {
20354 18 int32_t pos = args[0];
20355 18 int32_t upos = args[1];
20356 18 int32_t dpos = args[2];
20357 18 int32_t lpos = args[3];
20358 18 int32_t rpos = args[4];
20359
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
18 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20360 {
20361 2 ssc_tile_hei = ssc_tile_hei_buf;
20362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20363 2 ssc_tile_hei_buf = -1;
20364 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20366 2 cursor_x=msg_margins[left];
20367 2 }
20368
20369 36 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20370 18 upos, dpos, lpos, rpos);
20371
20372
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20373 18 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20374 18 return true;
20375 }
20376
20377 case MSGC_RUNMENU:
20378 {
20379 5 msg_menu_data[MNU_CHOSEN] = 0;
20380 5 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(menu_options.size() < 1)
20382 return true;
20383 5 do_run_menu = true;
20384 5 return true;
20385 }
20386
20387 case MSGC_GOTOMENUCHOICE:
20388 {
20389 7 int32_t choice = args[0];
20390
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(msg_menu_data[MNU_CHOSEN] == choice)
20391 {
20392 5 last_arg = 1;
20393 5 goto switched;
20394 }
20395
20396 2 return true;
20397 }
20398
20399 case MSGC_ENDSTRING:
20400 {
20401 3 do_end_str = true;
20402 3 return true;
20403 }
20404 case MSGC_WAIT_ADVANCE:
20405 {
20406 wait_advance = true;
20407 linkedmsgclk = 51;
20408 return true;
20409 }
20410 case MSGC_TRIGSECRETS:
20411 {
20412 bool perm = args[0];
20413 trigger_secrets_for_screen(TriggerSource::SCC, msgscr, false);
20414 if(perm)
20415 setmapflag(msgscr, mSECRET);
20416 return true;
20417 }
20418 case MSGC_TRIG_CMB_COPYCAT:
20419 {
20420 int copy_id = args[0];
20421 if(copy_id == byte(copy_id))
20422 trig_copycat(copy_id);
20423 return true;
20424 }
20425 case MSGC_SETSCREENSTATE:
20426 {
20427 int32_t flag = args[0];
20428 if(unsigned(flag)>=mMAXIND)
20429 {
20430 Z_error("SCC 133: Flag %d is invalid\n", flag);
20431 return true;
20432 }
20433 bool state = args[1];
20434 if(state)
20435 setmapflag(msgscr, 1<<flag);
20436 else
20437 unsetmapflag(msgscr, 1<<flag, true);
20438 return true;
20439 }
20440 case MSGC_SETSCREENSTATER:
20441 {
20442 int32_t map = args[0];
20443 int32_t scrid = args[1];
20444 if(map < 1 || map > map_count)
20445 {
20446 Z_error("SCC 134: Map %d is invalid\n", map);
20447 return true;
20448 }
20449 if(unsigned(scrid)>=0x80)
20450 {
20451 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20452 return true;
20453 }
20454
20455 int32_t flag = args[2];
20456 if(unsigned(flag)>=mMAXIND)
20457 {
20458 Z_error("SCC 134: Flag %d is invalid\n", flag);
20459 return true;
20460 }
20461 bool state = args[3];
20462 if(state)
20463 setmapflag_mi(msgscr, mapind(map,scrid),1<<flag);
20464 else
20465 unsetmapflag_mi(msgscr, mapind(map,scrid),1<<flag,true);
20466 return true;
20467 }
20468 switched:
20469 55 int32_t lev = args[last_arg];
20470
3/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
55 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20471
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 33 times.
54 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20472 {
20473 setmsg(lev);
20474 }
20475 else
20476 {
20477 55 donewmsg(msgscr, lev);
20478 55 ssc_tile_hei_buf = -1;
20479 }
20480 55 putprices(false);
20481 55 return true;
20482 }
20483
20484 return false;
20485 3293 }
20486
20487 3299 static std::string parsemsgcode2(const StringCommand& command)
20488 {
20489
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (command.code == MSGC_NAME)
20490 {
20491
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 return game->get_name();
20492 }
20493 else
20494 {
20495 3293 parsemsgcode(command);
20496 }
20497
20498
1/2
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
3293 return "";
20499 3299 }
20500
20501 252528 static bool putmsgchar(bool play_sfx)
20502 {
20503 DCHECK(msg_it->state == MsgStr::iterator::CHARACTER);
20504 DCHECK(!msg_it->character.empty());
20505
20506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252528 times.
252528 if (bottom_margin_clip())
20507 return false;
20508
20509 // If the current word would overflow the margins, increment cursor to the next line.
20510 252528 const char* rem_word = msg_it->remaining_word();
20511 252528 int tlength = text_length(msgfont, rem_word) + ((int32_t)strlen(rem_word)*MsgStrings[msgstr].hspace);
20512
4/4
✓ Branch 0 taken 5667 times.
✓ Branch 1 taken 246861 times.
✓ Branch 2 taken 494 times.
✓ Branch 3 taken 5081 times.
258103 if (cursor_x+tlength > (msg_w-msg_margins[right]) &&
20513
4/4
✓ Branch 0 taken 5575 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 5081 times.
✓ Branch 3 taken 92 times.
5667 ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) ? true : strcmp(rem_word," ")!=0))
20514 {
20515 5575 ssc_tile_hei = ssc_tile_hei_buf;
20516
1/2
✓ Branch 0 taken 5575 times.
✗ Branch 1 not taken.
5575 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20517 5575 ssc_tile_hei_buf = -1;
20518 5575 cursor_y += thei + MsgStrings[msgstr].vspace;
20519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5575 times.
5575 if (bottom_margin_clip()) return false;
20520
20521 5575 cursor_x = msg_margins[left];
20522 5575 }
20523
20524
2/2
✓ Branch 0 taken 34959 times.
✓ Branch 1 taken 217569 times.
252528 if (play_sfx)
20525 217569 sfx(MsgStrings[msgstr].sfx);
20526
20527 // Print the character (unless it's just a space).
20528
2/2
✓ Branch 0 taken 58979 times.
✓ Branch 1 taken 193549 times.
252528 if (msg_it->character != " ")
20529 193549 textout_styled_aligned_ex(msg_txt_bmp_buf, msgfont, msg_it->character.c_str(), cursor_x, cursor_y, msg_shdtype, sstaLEFT, msgcolour, msg_shdcol, -1);
20530
20531 // Move the cursor.
20532 252528 cursor_x += msgfont->vtable->text_length(msgfont, msg_it->character.c_str());
20533
2/2
✓ Branch 0 taken 58979 times.
✓ Branch 1 taken 193549 times.
252528 if (msg_it->character != " ")
20534 193549 cursor_x += MsgStrings[msgstr].hspace;
20535
20536 252528 return true;
20537 252528 }
20538
20539 enum msg_tick_result {msg_tick_exit, msg_tick_break, msg_tick_continue};
20540
20541 static void msg_tick_end(bool disappear = false);
20542 241586 static msg_tick_result msg_tick(bool play_sfx, bool burst_mode)
20543 {
20544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241586 times.
241586 if (msg_it->done())
20545 return msg_tick_exit;
20546
20547
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 239555 times.
241586 if (!do_run_menu)
20548 {
20549
4/4
✓ Branch 0 taken 239555 times.
✓ Branch 1 taken 3299 times.
✓ Branch 2 taken 3299 times.
✓ Branch 3 taken 239555 times.
242854 while (msg_it->state == MsgStr::iterator::COMMAND && !do_run_menu)
20550 {
20551 3299 bool one_frame_command_delay = !replay_version_check(41);
20552 3299 std::string text = parsemsgcode2(msg_it->command);
20553
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (text.empty())
20554 {
20555
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3293 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3293 times.
3293 msg_it->set_buffer("");
20556 // Advance the iterator to run many commands in one frame.
20557
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 3169 times.
3293 if (!one_frame_command_delay)
20558
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 msg_it->next();
20559 3293 }
20560 else
20561 {
20562
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 msg_it->set_buffer(text);
20563
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 msg_it->next();
20564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (one_frame_command_delay)
20565 6 msg_it->post_segment_delay = 1;
20566 }
20567 3299 }
20568
20569
2/2
✓ Branch 0 taken 3177 times.
✓ Branch 1 taken 236378 times.
239555 if (msg_it->state == MsgStr::iterator::CHARACTER)
20570 {
20571
1/2
✓ Branch 0 taken 236378 times.
✗ Branch 1 not taken.
236378 if (!putmsgchar(play_sfx)) return msg_tick_break;
20572 236378 }
20573 239555 }
20574
20575 241586 bool wait_advance_check_early = !burst_mode;
20576
20577
2/2
✓ Branch 0 taken 78489 times.
✓ Branch 1 taken 163097 times.
241586 if (wait_advance_check_early)
20578 {
20579
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 163096 times.
163097 if (do_end_str)
20580 {
20581 1 msg_tick_end();
20582 1 return msg_tick_exit;
20583 }
20584
20585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 163096 times.
163096 if (wait_advance)
20586 {
20587 msg_it->next();
20588 return msg_tick_exit;
20589 }
20590 163096 }
20591
20592
2/2
✓ Branch 0 taken 239549 times.
✓ Branch 1 taken 2036 times.
241585 if (do_run_menu)
20593 {
20594
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2031 times.
2036 if (runMenuCursor())
20595 {
20596 5 do_run_menu = false;
20597
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (!burst_mode)
20598 {
20599 2 msg_it->next();
20600 2 return msg_tick(play_sfx, burst_mode);
20601 }
20602 3 }
20603 2031 else return msg_tick_break;
20604 3 }
20605
20606 239552 msg_it->next();
20607
20608
2/2
✓ Branch 0 taken 161597 times.
✓ Branch 1 taken 77955 times.
239552 if (!wait_advance_check_early)
20609 {
20610
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 77953 times.
77955 if (do_end_str)
20611 {
20612 2 msg_tick_end();
20613 2 return msg_tick_exit;
20614 }
20615
20616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77953 times.
77953 if (wait_advance)
20617 return msg_tick_exit;
20618 77953 }
20619
20620
4/4
✓ Branch 0 taken 4002 times.
✓ Branch 1 taken 235548 times.
✓ Branch 2 taken 1986 times.
✓ Branch 3 taken 2016 times.
239550 if (msg_it->done() && MsgStrings[msgstr].nextstring)
20621 {
20622
1/2
✓ Branch 0 taken 2016 times.
✗ Branch 1 not taken.
2016 if (MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20623 setmsg(MsgStrings[msgstr].nextstring);
20624 2016 }
20625
20626 239550 return msg_tick_continue;
20627 241586 }
20628
20629 165380 static void msg_tick_end(bool disappear)
20630 {
20631
2/2
✓ Branch 0 taken 164371 times.
✓ Branch 1 taken 1009 times.
165380 if (disappear)
20632 1009 goto disappear;
20633
20634 // Done printing the string
20635
8/8
✓ Branch 0 taken 164368 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 162871 times.
✓ Branch 3 taken 1497 times.
✓ Branch 4 taken 158850 times.
✓ Branch 5 taken 4021 times.
✓ Branch 6 taken 158850 times.
✓ Branch 7 taken 4021 times.
164371 if (do_end_str || !do_run_menu && (msg_it->done() || bottom_margin_clip()) && !linkedmsgclk)
20636 {
20637
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4021 times.
4024 if(!do_end_str)
20638 {
20639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4021 times.
4021 while (msg_it->state == MsgStr::iterator::COMMAND)
20640 {
20641 parsemsgcode2(msg_it->command);
20642 msg_it->next();
20643 }
20644 4021 }
20645
20646 // Go to next string, or make it disappear by going to string 0.
20647
5/6
✓ Branch 0 taken 2006 times.
✓ Branch 1 taken 2018 times.
✓ Branch 2 taken 996 times.
✓ Branch 3 taken 1010 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 996 times.
4024 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
20648 {
20649 3028 linkedmsgclk=do_end_str?1:51;
20650 3028 }
20651
20652
2/2
✓ Branch 0 taken 2006 times.
✓ Branch 1 taken 2018 times.
4024 if(MsgStrings[msgstr].nextstring==0)
20653 {
20654
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 996 times.
2006 if(!get_qr(qr_MSGDISAPPEAR))
20655 996 {
20656 disappear:
20657 2005 msg_active = false;
20658 2005 Hero.finishedmsg();
20659 2005 }
20660
20661
2/2
✓ Branch 0 taken 3002 times.
✓ Branch 1 taken 13 times.
3015 if(repaircharge)
20662 {
20663
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 game->change_drupy(-(cur_screen >= 128 ? special_warp_return_scr : msgscr)->catchall);
20664 13 repaircharge = 0;
20665 13 }
20666
20667
2/2
✓ Branch 0 taken 3013 times.
✓ Branch 1 taken 2 times.
3015 if(adjustmagic)
20668 {
20669
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
20670 {
20671
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(game->get_magicdrainrate())
20672 2 game->set_magicdrainrate(1);
20673 2 }
20674 else if(game->get_magicdrainrate() > 1)
20675 {
20676 game->set_magicdrainrate(game->get_magicdrainrate()/2);
20677 }
20678 2 adjustmagic = false;
20679 2 sfx(WAV_SCALE);
20680
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20681 2 }
20682
20683
2/2
✓ Branch 0 taken 3013 times.
✓ Branch 1 taken 2 times.
3015 if(learnslash)
20684 {
20685 2 game->set_canslash(1);
20686 2 learnslash = false;
20687 2 sfx(WAV_SCALE);
20688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20689 2 }
20690 3015 }
20691 5033 }
20692 165380 }
20693
20694 6223 static void msg_consume_spaces()
20695 {
20696
2/2
✓ Branch 0 taken 6223 times.
✓ Branch 1 taken 16150 times.
22373 while (msg_it->character == " ")
20697 {
20698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16150 times.
16150 if (!putmsgchar(false)) break;
20699
20700 // Advance the iterator.
20701 16150 msg_it->next();
20702
20703 // The "Continue From Previous" feature
20704
1/2
✓ Branch 0 taken 16150 times.
✗ Branch 1 not taken.
16150 if (msg_it->state == MsgStr::iterator::DONE)
20705 {
20706 if(MsgStrings[msgstr].nextstring)
20707 {
20708 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20709 {
20710 setmsg(MsgStrings[msgstr].nextstring);
20711 }
20712 }
20713 }
20714 }
20715 6223 }
20716
20717 14597416 void putmsg()
20718 {
20719
2/2
✓ Branch 0 taken 682091 times.
✓ Branch 1 taken 13915325 times.
14597416 if(!msgorig) msgorig=msgstr;
20720
20721
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14597416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14597416 if(wait_advance && linkedmsgclk < 1)
20722 linkedmsgclk = 1;
20723
2/2
✓ Branch 0 taken 14319520 times.
✓ Branch 1 taken 277896 times.
14597416 if(linkedmsgclk>0)
20724 {
20725
2/2
✓ Branch 0 taken 126695 times.
✓ Branch 1 taken 151201 times.
277896 if(linkedmsgclk==1)
20726 {
20727
6/6
✓ Branch 0 taken 126692 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 123787 times.
✓ Branch 3 taken 2905 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 123669 times.
126695 if(do_end_str||cAbtn()||cBbtn())
20728 {
20729 3026 do_end_str = false;
20730 3026 linkedmsgclk = 0;
20731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3026 times.
3026 if(wait_advance)
20732 {
20733 wait_advance = false;
20734 }
20735 else
20736 {
20737
1/2
✓ Branch 0 taken 3026 times.
✗ Branch 1 not taken.
3026 if (!msgscr) msgscr = hero_scr;
20738 3026 msgstr=MsgStrings[msgstr].nextstring;
20739 3026 ssc_tile_hei_buf = -1;
20740
3/4
✓ Branch 0 taken 1009 times.
✓ Branch 1 taken 2017 times.
✓ Branch 2 taken 1009 times.
✗ Branch 3 not taken.
3026 if(!msgstr && enqueued_str)
20741 {
20742 msgstr = enqueued_str;
20743 enqueued_str = 0;
20744 }
20745
2/2
✓ Branch 0 taken 2017 times.
✓ Branch 1 taken 1009 times.
3026 if(!msgstr)
20746 {
20747 1009 msgfont=get_zc_font(font_zfont);
20748
20749
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1005 times.
1009 if(msgscr->room!=rGRUMBLE)
20750 1005 blockpath=false;
20751
20752 1009 dismissmsg();
20753 1009 msg_tick_end(true);
20754 1009 return;
20755 }
20756
20757 2017 donewmsg(msgscr, msgstr);
20758 2017 putprices(false);
20759 }
20760 2017 }
20761 125686 }
20762 else
20763 {
20764 151201 --linkedmsgclk;
20765 }
20766 276887 }
20767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14596407 times.
14596407 if(wait_advance) return; //Waiting for buttonpress
20768
20769
7/8
✓ Branch 0 taken 14593554 times.
✓ Branch 1 taken 2853 times.
✓ Branch 2 taken 676270 times.
✓ Branch 3 taken 13917284 times.
✓ Branch 4 taken 259186 times.
✓ Branch 5 taken 417084 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 259186 times.
14596407 if(!do_run_menu && (!msgstr || msg_it->done() || bottom_margin_clip()))
20770 {
20771
2/2
✓ Branch 0 taken 417084 times.
✓ Branch 1 taken 13917284 times.
14334368 if(!msgstr)
20772 13917284 msgorig=0;
20773
20774 14334368 msg_active = false;
20775 14334368 msg_it.reset();
20776 14334368 return;
20777 }
20778
20779 262039 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
20780
20781
2/2
✓ Branch 0 taken 257995 times.
✓ Branch 1 taken 4044 times.
262039 if (msg_it->state == MsgStr::iterator::NOT_STARTED)
20782 {
20783 4044 msg_it->next();
20784 4044 msg_consume_spaces();
20785 4044 }
20786
20787 // If the player is holding down the B button, or if msgspeed is 0, process as many characters
20788 // as possible. This skips the character-by-character animation that usually renders a string
20789 // slowly over many frames.
20790
4/4
✓ Branch 0 taken 1381 times.
✓ Branch 1 taken 260658 times.
✓ Branch 2 taken 1795 times.
✓ Branch 3 taken 258863 times.
262039 if ((cBbtn() && get_qr(qr_ALLOWMSGBYPASS)) || msgspeed == 0)
20791 {
20792
2/2
✓ Branch 0 taken 1274 times.
✓ Branch 1 taken 78499 times.
81129 while (!msg_it->done())
20793 {
20794
5/6
✓ Branch 0 taken 20654 times.
✓ Branch 1 taken 57845 times.
✓ Branch 2 taken 20644 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 20644 times.
✗ Branch 5 not taken.
78499 if (msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
20795 10 goto breakout; // break out if message speed was changed to non-zero
20796
20797 78489 auto tick = msg_tick(msg_it->character != " ", true);
20798
2/2
✓ Branch 0 taken 77955 times.
✓ Branch 1 taken 534 times.
78489 if (tick == msg_tick_break)
20799 534 break;
20800
2/2
✓ Branch 0 taken 77953 times.
✓ Branch 1 taken 2 times.
77955 if (tick == msg_tick_exit)
20801 2 return;
20802 }
20803
20804
2/2
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 1274 times.
1808 if (!do_run_menu)
20805 {
20806 1274 msgclk = 72;
20807 1274 }
20808 1808 }
20809 else
20810 258863 {
20811 breakout:
20812 258873 word tempspeed = msgspeed;
20813
2/2
✓ Branch 0 taken 257910 times.
✓ Branch 1 taken 963 times.
258873 if (do_run_menu)
20814 963 tempspeed = 0;
20815
6/6
✓ Branch 0 taken 207648 times.
✓ Branch 1 taken 51225 times.
✓ Branch 2 taken 121413 times.
✓ Branch 3 taken 86235 times.
✓ Branch 4 taken 111336 times.
✓ Branch 5 taken 10077 times.
258873 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
20816 96312 return;
20817 }
20818
20819 // Process the next msg tick.
20820 // This will either print a single character, or process a single string command (with one
20821 // exception).
20822
3/4
✓ Branch 0 taken 163095 times.
✓ Branch 1 taken 1274 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 163095 times.
164369 if (!msg_it->done() && !bottom_margin_clip())
20823 {
20824 // This may run an additional tick in the case of a string menu finishing: the first
20825 // tick wraps up the menu, and then a second tick processes the next character or command.
20826 163095 auto tick = msg_tick(true, false);
20827
2/2
✓ Branch 0 taken 1497 times.
✓ Branch 1 taken 161598 times.
163095 if (tick == msg_tick_break)
20828 {
20829 1497 msg_tick_end();
20830 1497 return;
20831 }
20832
2/2
✓ Branch 0 taken 161597 times.
✓ Branch 1 taken 1 times.
161598 if (tick == msg_tick_exit)
20833 1 return;
20834
20835 // If the next two characters are spaces, consume all upcoming spaces now.
20836
13/20
✓ Branch 0 taken 2747 times.
✓ Branch 1 taken 158850 times.
✓ Branch 2 taken 158850 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26224 times.
✓ Branch 5 taken 132626 times.
✓ Branch 6 taken 26224 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 26224 times.
✓ Branch 10 taken 135373 times.
✓ Branch 11 taken 26224 times.
✓ Branch 12 taken 2747 times.
✓ Branch 13 taken 158850 times.
✓ Branch 14 taken 159418 times.
✓ Branch 15 taken 2179 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
187821 if (!msg_it->done() && msg_it->peek(0) == " " && msg_it->peek(1) == " ")
20837 2179 msg_consume_spaces();
20838 161597 }
20839
20840 162871 msg_tick_end();
20841 14596060 }
20842
20843 124698 int32_t message_more_y()
20844 {
20845 //Is the flag ticked, do we really want a message more y larger than 160?
20846
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 124670 times.
✓ Branch 2 taken 124698 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124670 times.
✓ Branch 5 taken 28 times.
124698 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
20847 124698 msgy+=playing_field_offset;
20848 124698 return msgy;
20849 }
20850
20851 /*** Collision detection & handling ***/
20852
20853 14285055 void clear_script_one_frame_conditions()
20854 {
20855
2/2
✓ Branch 0 taken 38964316 times.
✓ Branch 1 taken 14285055 times.
53249371 for(int32_t j=0; j<guys.Count(); j++)
20856 {
20857 38964316 enemy *e = (enemy*)guys.spr(j);
20858
2/2
✓ Branch 0 taken 662393372 times.
✓ Branch 1 taken 38964316 times.
701357688 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
20859 38964316 }
20860 14285055 }
20861
20862 4877097 void check_enemy_lweapon_collision(weapon *w)
20863 {
20864
8/8
✓ Branch 0 taken 4260707 times.
✓ Branch 1 taken 616390 times.
✓ Branch 2 taken 3264982 times.
✓ Branch 3 taken 995725 times.
✓ Branch 4 taken 3202840 times.
✓ Branch 5 taken 62142 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 3186102 times.
4877097 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
20865 {
20866
2/2
✓ Branch 0 taken 3170476 times.
✓ Branch 1 taken 11197341 times.
14367817 for(int32_t j=0; j<guys.Count(); j++)
20867 {
20868 11197341 enemy *e = (enemy*)guys.spr(j);
20869
20870 11197341 bool didhit = e->hit(w);
20871
2/2
✓ Branch 0 taken 10976716 times.
✓ Branch 1 taken 220625 times.
11197341 if(didhit) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
20872 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
20873 {
20874 // !(e->stunclk)
20875 220625 int32_t h = e->takehit(w);
20876
2/2
✓ Branch 0 taken 187136 times.
✓ Branch 1 taken 33489 times.
220625 if (h == -1)
20877 {
20878 33489 int indx = Lwpns.find(w);
20879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33489 times.
33489 if(indx > -1)
20880 33489 e->hitby[HIT_BY_LWEAPON] = indx+1;
20881 33489 e->hitby[HIT_BY_LWEAPON_UID] = w->getUID();
20882 33489 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
20883
2/2
✓ Branch 0 taken 31272 times.
✓ Branch 1 taken 2217 times.
33489 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
20884 2217 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
20885 33489 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
20886 33489 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
20887
20888 33489 }
20889 //we may need to handle this in special cases. -Z
20890
20891 //if h == stun or ignore
20892
20893 //if e->stun > DEFAULT_STUN -1 || !e->stun
20894 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
20895 ///! how about: if w->dead != bounce !
20896
20897 // NOT FOR PUBLIC RELEASE
20898 /*if(h==3) //Mirror shield
20899 {
20900 if (w->id==ewFireball || w->id==wRefFireball)
20901 {
20902 w->id=wRefFireball;
20903 switch(e->dir)
20904 {
20905 case up: e->angle += (PI - e->angle) * 2.0; break;
20906 case down: e->angle = -e->angle; break;
20907 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
20908 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
20909 // TODO: the following. -L.
20910 case l_up: break;
20911 case r_up: break;
20912 case l_down: break;
20913 case r_down: break;
20914 }
20915 }
20916 else
20917 {
20918 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
20919 w->dir ^= 1;
20920 if(w->dir&2)
20921 w->flip ^= 1;
20922 else
20923 w->flip ^= 2;
20924 }
20925 w->ignoreHero=false;
20926 }
20927 else*/
20928
2/2
✓ Branch 0 taken 176531 times.
✓ Branch 1 taken 44094 times.
220625 if(h)
20929 {
20930
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 44090 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
44094 if(e->switch_hooked && w->family_class == itype_switchhook)
20931 w->onhit(false, e, -1);
20932 44094 else w->onhit(false, e, h);
20933 44094 }
20934
20935
2/2
✓ Branch 0 taken 217951 times.
✓ Branch 1 taken 2674 times.
220625 if(h==2)
20936 {
20937 2674 break;
20938 }
20939 217951 }
20940
20941
2/2
✓ Branch 0 taken 11181715 times.
✓ Branch 1 taken 12952 times.
11194667 if(w->Dead())
20942 {
20943 12952 break;
20944 }
20945 11181715 }
20946
20947 // Item flags added in 2.55:
20948 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
20949 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
20950 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
20951 // -Em
20952
6/6
✓ Branch 0 taken 2731659 times.
✓ Branch 1 taken 454443 times.
✓ Branch 2 taken 2686973 times.
✓ Branch 3 taken 44686 times.
✓ Branch 4 taken 44438 times.
✓ Branch 5 taken 2642535 times.
3186102 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
20953 {
20954 543567 int32_t itype, pitem = w->parentitem;
20955
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 454443 times.
✓ Branch 2 taken 44438 times.
✓ Branch 3 taken 44686 times.
543567 switch(w->id)
20956 {
20957 454443 case wBrang: itype = itype_brang; break;
20958 44438 case wArrow: itype = itype_arrow; break;
20959 case wHookshot:
20960 44686 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
20961 44686 break;
20962 }
20963
2/2
✓ Branch 0 taken 538526 times.
✓ Branch 1 taken 5041 times.
543567 if(pitem < 0) pitem = current_item_id(itype);
20964
5/6
✓ Branch 0 taken 44686 times.
✓ Branch 1 taken 498881 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44586 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
543567 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
20965 { //Swap with item
20966 for(int32_t j=0; j<items.Count(); j++)
20967 {
20968 if(items.spr(j)->hit(w))
20969 {
20970 item *theItem = ((item*)items.spr(j));
20971 bool priced = theItem->PriceIndex >-1;
20972 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
20973 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20974 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20975 {
20976 if(!Hero.switchhookclk)
20977 {
20978 hooked_comborpos = rpos_t::None;
20979 hooked_layerbits = 0;
20980 switching_object = theItem;
20981 theItem->switch_hooked = true;
20982 w->misc = 2;
20983 w->step = 0;
20984 theItem->clk2=256;
20985 Hero.doSwitchHook(game->get_switchhookstyle());
20986 if(QMisc.miscsfx[sfxSWITCHED])
20987 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
20988 }
20989 }
20990 }
20991 }
20992 }
20993
6/6
✓ Branch 0 taken 44438 times.
✓ Branch 1 taken 499129 times.
✓ Branch 2 taken 374939 times.
✓ Branch 3 taken 330501 times.
✓ Branch 4 taken 499129 times.
✓ Branch 5 taken 330501 times.
543567 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
20994 {
20995
2/2
✓ Branch 0 taken 88886 times.
✓ Branch 1 taken 374939 times.
463825 for(int32_t j=0; j<items.Count(); j++)
20996 {
20997
2/2
✓ Branch 0 taken 83988 times.
✓ Branch 1 taken 4898 times.
88886 if(items.spr(j)->hit(w))
20998 {
20999 4898 item *theItem = ((item*)items.spr(j));
21000 4898 bool priced = theItem->PriceIndex >-1;
21001
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4766 times.
4898 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21002
5/8
✓ Branch 0 taken 4898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6963 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21003
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4898 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
21004 {
21005
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
21006 {
21007 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
21008 }
21009
21010 1724 Hero.checkitems(j);
21011 1724 }
21012 4898 }
21013 88886 }
21014 374939 }
21015
2/2
✓ Branch 0 taken 15347 times.
✓ Branch 1 taken 153281 times.
829630 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
21016 {
21017
2/2
✓ Branch 0 taken 36900 times.
✓ Branch 1 taken 153281 times.
190181 for(int32_t j=0; j<items.Count(); j++)
21018 {
21019
2/2
✓ Branch 0 taken 28212 times.
✓ Branch 1 taken 8688 times.
36900 if(items.spr(j)->hit(w))
21020 {
21021 8688 item *theItem = ((item*)items.spr(j));
21022 8688 bool priced = theItem->PriceIndex >-1;
21023
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8681 times.
8688 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21024
4/6
✓ Branch 0 taken 8688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8454 times.
✓ Branch 5 taken 234 times.
8688 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21025
5/10
✓ Branch 0 taken 7273 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 1415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1415 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8688 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21026 {
21027 7273 int32_t pickup = theItem->pickup;
21028 7273 int32_t id2 = theItem->id;
21029 7273 int32_t pstr = theItem->pstring;
21030 7273 int32_t pstr_flags = theItem->pickup_string_flags;
21031
21032 7273 std::vector<int32_t> &ev = FFCore.eventData;
21033 7273 ev.clear();
21034 7273 ev.push_back(id2*10000);
21035 7273 ev.push_back(pickup*10000);
21036 7273 ev.push_back(pstr*10000);
21037 7273 ev.push_back(pstr_flags*10000);
21038 7273 ev.push_back(0);
21039 7273 ev.push_back(theItem->getUID());
21040 7273 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
21041 7273 ev.push_back(w->getUID());
21042
21043 7273 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
21044 7273 bool nullify = ev[4] != 0;
21045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7273 times.
7273 if(nullify) continue;
21046
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6197 times.
7273 if(w->id == wBrang)
21047 {
21048 6197 w->onhit(false);
21049 6197 }
21050
21051
2/2
✓ Branch 0 taken 6775 times.
✓ Branch 1 taken 498 times.
7273 if(w->dragging==-1)
21052 {
21053 498 w->dead=1;
21054 498 theItem->clk2=256;
21055 498 w->dragging=j;
21056 498 theItem->is_dragged = true;
21057 498 }
21058 7273 }
21059 8688 }
21060 36900 }
21061 153281 }
21062 543567 }
21063 3186102 }
21064 4877097 }
21065 14282888 void check_collisions()
21066 {
21067
2/2
✓ Branch 0 taken 4877062 times.
✓ Branch 1 taken 14282888 times.
19159950 for(uint q = 0; q < Lwpns.Count(); ++q)
21068 4877062 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
21069 14282888 }
21070
21071 14285055 void dragging_item()
21072 {
21073
2/2
✓ Branch 0 taken 4993116 times.
✓ Branch 1 taken 14285055 times.
19278171 for(int32_t i=0; i<Lwpns.Count(); i++)
21074 {
21075 4993116 weapon *w = (weapon*)Lwpns.spr(i);
21076
21077
4/4
✓ Branch 0 taken 4530081 times.
✓ Branch 1 taken 463035 times.
✓ Branch 2 taken 4837857 times.
✓ Branch 3 taken 155259 times.
4993116 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
21078 {
21079
3/4
✓ Branch 0 taken 7247 times.
✓ Branch 1 taken 148012 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7247 times.
155259 if(w->dragging>=0 && w->dragging<items.Count())
21080 {
21081 7247 item* dragItem = (item*)items.spr(w->dragging);
21082 7247 dragItem->x=w->x;
21083 7247 dragItem->y=w->y;
21084
21085 // Drag the Fairy enemy as well as the Fairy item
21086 7247 int32_t id = dragItem->id;
21087
21088
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 6828 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7247 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
21089 {
21090 404 movefairynew2(w->x,w->y,*dragItem);
21091 404 }
21092 7247 }
21093 155259 }
21094 4993116 }
21095 14285055 }
21096
21097 57 int32_t more_carried_items(int screen)
21098 {
21099 57 int32_t hasmorecarries = 0;
21100
21101
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 57 times.
121 for(int32_t i=0; i<items.Count(); i++)
21102 {
21103 64 auto spr = (item*)items.spr(i);
21104
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 57 times.
64 if (spr->screen_spawned == screen && (spr->pickup & ipENEMY))
21105 {
21106 57 hasmorecarries++;
21107 57 }
21108 64 }
21109
21110 57 return hasmorecarries;
21111 }
21112
21113 36105 static int count_guys_from_screen(int screen)
21114 {
21115 36105 int count = 0;
21116
2/2
✓ Branch 0 taken 235232 times.
✓ Branch 1 taken 36105 times.
271337 for (int i=0; i < guys.Count(); i++)
21117 {
21118
2/2
✓ Branch 0 taken 36538 times.
✓ Branch 1 taken 198694 times.
235232 if (((enemy*)guys.spr(i))->screen_spawned == screen)
21119 198694 count += 1;
21120 235232 }
21121 36105 return count;
21122 }
21123
21124 // messy code to do the enemy-carrying-the-item thing
21125 14672983 static void roaming_item(mapscr* scr)
21126 {
21127 14672983 int screen = scr->screen;
21128 14672983 auto& state = get_screen_state(screen);
21129
4/4
✓ Branch 0 taken 14636939 times.
✓ Branch 1 taken 36044 times.
✓ Branch 2 taken 14636878 times.
✓ Branch 3 taken 36105 times.
14672983 if (!(state.item_state == ScreenItemState::CarriedByEnemy || state.item_state == ScreenItemState::MustGiveToEnemy) || !state.loaded_enemies)
21130 14636878 return;
21131
21132 // All enemies already dead upon entering a room?
21133
1/2
✓ Branch 0 taken 36105 times.
✗ Branch 1 not taken.
36105 if (count_guys_from_screen(screen) == 0)
21134 {
21135 return;
21136 }
21137
21138 36105 int guycarryingitem = -1;
21139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84114 times.
84114 for(int32_t j=0; j<guys.Count(); j++)
21140 {
21141 84114 enemy* e = (enemy*)guys.spr(j);
21142
4/4
✓ Branch 0 taken 62420 times.
✓ Branch 1 taken 21694 times.
✓ Branch 2 taken 26315 times.
✓ Branch 3 taken 36105 times.
84114 if (e->screen_spawned == screen && e->itemguy)
21143 {
21144 36105 guycarryingitem=j;
21145 36105 break;
21146 }
21147 48009 }
21148
21149
2/2
✓ Branch 0 taken 36029 times.
✓ Branch 1 taken 76 times.
36105 if (state.item_state == ScreenItemState::MustGiveToEnemy)
21150 {
21151
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(guycarryingitem == -1) //This happens when "default enemies" such as
21152 {
21153 return; //eSHOOTFBALL are alive but enemies from the list
21154 } //are not. Defer to HeroClass::checkspecial().
21155
21156 76 int32_t Item=scr->item;
21157
21158 76 state.item_state = ScreenItemState::None;
21159
21160
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
76 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
21161 {
21162 152 auto [x, y] = translate_screen_coordinates_to_world(screen);
21163 215 additem(x,y,Item,ipENEMY+ipONETIME+ipBIGRANGE
21164
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 13 times.
76 + (((scr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
21165 );
21166 76 ((item*)items.spr(items.Count() - 1))->screen_spawned = screen;
21167 76 state.item_state = ScreenItemState::CarriedByEnemy;
21168 76 }
21169 else
21170 {
21171 return;
21172 }
21173 76 }
21174
21175
2/2
✓ Branch 0 taken 45397 times.
✓ Branch 1 taken 36105 times.
81502 for(int32_t i=0; i<items.Count(); i++)
21176 {
21177
4/4
✓ Branch 0 taken 42003 times.
✓ Branch 1 taken 3394 times.
✓ Branch 2 taken 5898 times.
✓ Branch 3 taken 36105 times.
45397 if(((item*)items.spr(i))->pickup&ipENEMY && ((item*)items.spr(i))->screen_spawned == screen)
21178 {
21179
2/2
✓ Branch 0 taken 22240 times.
✓ Branch 1 taken 13865 times.
36105 if(get_qr(qr_HIDECARRIEDITEMS))
21180 {
21181 22240 items.spr(i)->x = -128; // Awfully inelegant, innit?
21182 22240 items.spr(i)->y = -128;
21183 22240 }
21184
2/4
✓ Branch 0 taken 13865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13865 times.
13865 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21185 {
21186
1/2
✓ Branch 0 taken 13865 times.
✗ Branch 1 not taken.
13865 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21187 {
21188 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21189 {
21190 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21191 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21192 }
21193 else
21194 {
21195 if(guys.spr(guycarryingitem)->extend >= 3)
21196 {
21197 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21198 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21199 }
21200 else
21201 {
21202 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21203 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21204 }
21205 }
21206 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21207 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21208 }
21209 else
21210 {
21211 13865 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21212 13865 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21213 13865 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21214 }
21215 13865 }
21216 36105 }
21217 45397 }
21218 14672983 }
21219
21220 14285055 void roaming_item()
21221 {
21222 28958038 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
21223 14672983 roaming_item(scr);
21224 14672983 });
21225 14285055 }
21226
21227 bool enemy::IsBigAnim()
21228 {
21229 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21230 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21231 || anim == a4FRM8DIRB);
21232 }
21233 2406431 int32_t enemy::getFlashingCSet()
21234 {
21235 //Special cset for the dying sprite
21236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2406431 times.
2406431 if(dying)
21237 {
21238 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21239 return wpnsbuf[spr_death].csets & 15;
21240 else
21241 return (((clk2 + 5) >> 1) & 3) + 6;
21242 }
21243
21244 //Normal cset
21245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2406431 times.
2406431 if (hclk <= 0)
21246 {
21247 //Special cset for the flashing animation
21248 if (flags & guy_flashing)
21249 return (frame & 3) + 6;
21250 return cs;
21251 }
21252
21253 //Hurt animations
21254
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2402543 times.
2406431 if(family==eeGANON)
21255 3888 return (((hclk-1)>>1)&3)+6;
21256
4/4
✓ Branch 0 taken 2232984 times.
✓ Branch 1 taken 169559 times.
✓ Branch 2 taken 487138 times.
✓ Branch 3 taken 1745846 times.
2402543 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21257 1745846 return (((hclk-1)>>1)&3)+6;
21258
21259 656697 return cs;
21260 2406431 }
21261
21262 81920617 bool enemy::is_hitflickerframe(bool olddrawing)
21263 {
21264
6/6
✓ Branch 0 taken 81892113 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 3959941 times.
✓ Branch 3 taken 77932172 times.
✓ Branch 4 taken 3187250 times.
✓ Branch 5 taken 772691 times.
81920617 if (family == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21265 81147926 return false;
21266
21267
3/4
✓ Branch 0 taken 496051 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 496051 times.
✗ Branch 3 not taken.
772691 if (!olddrawing && !getCanFlicker())
21268 return false;
21269
21270 772691 int32_t fr = game->get_spriteflickerspeed();
21271
1/2
✓ Branch 0 taken 772691 times.
✗ Branch 1 not taken.
772691 if (fr == 0)
21272 return true;
21273 772691 return frame % (fr * 2) < fr;
21274 81920617 }
21275
21276 const char *old_guy_string[OLDMAXGUYS] =
21277 {
21278 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21279 // 020
21280 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21281 // 025
21282 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21283 // 030
21284 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21285 // 035
21286 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21287 // 040
21288 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21289 // 045
21290 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21291 // 050
21292 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21293 // 055
21294 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21295 // 060
21296 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21297 // 065
21298 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21299 // 070
21300 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21301 // 075
21302 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21303 // 080
21304 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21305 // 085
21306 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21307 // 090
21308 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21309 // 095
21310 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21311 // 100
21312 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21313 // 105
21314 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21315 // 110
21316 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21317 // 115
21318 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21319 // 120
21320 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21321 // 125
21322 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21323 // 130
21324 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21325 // 135
21326 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21327 // 140
21328 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21329 // 145
21330 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21331 // 150
21332 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21333 // 155
21334 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21335 // 160
21336 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21337 // 165
21338 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21339 // 170
21340 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21341 // 175
21342 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21343 };
21344